This repository was archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsnapchatfinder_test.py
61 lines (48 loc) · 2.06 KB
/
snapchatfinder_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Author: Stan Fortoński
# Date: 06.05.2020
# Snapchat Finder Test
import sys, unittest
sys.path.insert(0, '..')
from time import sleep
from driver import getDriver
from tinder.config import Config
from tinder.login.tinderlogin import TinderLogin
from tinder.finder.snapchatfinder import SnapchatFinder
from selenium.common.exceptions import JavascriptException
class TestSnapchatFinder(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = getDriver()
cls.login = TinderLogin(cls.driver)
cls.login.logIn()
@classmethod
def tearDownClass(cls):
cls.driver.close()
def setUp(self):
self.snap = SnapchatFinder(self.driver)
def changeNameScript(self, name):
while True:
try:
self.driver.execute_script('document.querySelector("#content > div > div:nth-child(1) > div > main > div:nth-child(1) > div > div > div:nth-child(1) > div > div:nth-child(1) > div:nth-child(3) > div:nth-child(6) > div > div:nth-child(2) > div > div > span").innerHTML = "'+name+'"')
break
except:
self.driver.get('https://tinder.com/app/recs')
sleep(5)
def testSnapSaving(self):
testFileName = Config['snap_file_path']
with open(testFileName, 'w') as file:
file.write('')
self.changeNameScript('snap _x_te2st_x_')
self.assertTrue(self.snap.findAndSaveNick(testFileName))
self.changeNameScript('snap: _x_te2st_x_')
self.assertTrue(self.snap.findAndSaveNick(testFileName))
self.changeNameScript('snap:_x_te2st_x_')
self.assertTrue(self.snap.findAndSaveNick(testFileName))
self.changeNameScript('snapchat _x_te2st_x_')
self.assertTrue(self.snap.findAndSaveNick(testFileName))
self.changeNameScript('snapchat: _x_te2st_x_')
self.assertTrue(self.snap.findAndSaveNick(testFileName))
self.changeNameScript('snapchat:_x_te2st_x_')
self.assertTrue(self.snap.findAndSaveNick(testFileName))
if __name__ == '__main__':
unittest.main()