-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
134 lines (104 loc) · 3.13 KB
/
main.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# code not clean
import subprocess,sys,time,random,getpass
def install(name):
subprocess.call(['pip3', 'install', name])
try:
from selenium import webdriver
except ImportError:
install("selenium")
from selenium import webdriver
try:
from webdriver_manager.chrome import ChromeDriverManager
except:
install("webdriver-manager")
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
if __name__=='__main__':
args = sys.argv
n=len(args)
if n>1:
url = args[1]
if n>2:
code = args[2]
if n>3:
email = args[3]
if n>4:
passwd = args[4]
if n>5:
delay = args[5]
if n<2:
url = input('Enter your test url: ')
if n<3:
code = input('Enter your test code: ')
if n<4:
email = input('Enter your email: ')
if n<5:
passwd = getpass.getpass()
delay = 2
delay = min(60*60,delay)
if url[:4]!='http':
url='https://'+url
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
driver = webdriver.Chrome(ChromeDriverManager().install(),options=options)
try:
driver.get(url)
except:
print('\33[91m'+'INVALID URL'+'\033[0m')
exit()
for i in driver.find_elements_by_tag_name("a"):
if i.get_attribute("text")=="Get Started":
i.click()
break
for i in driver.find_elements_by_tag_name("input"):
if i.get_attribute("name")=="log_userName":
i.send_keys(email)
if i.get_attribute("name")=="log_pwd":
i.send_keys(passwd)
if i.get_attribute("value")=="Log In":
i.click()
break
try:
found=False
for i in driver.find_elements_by_tag_name("input"):
if i.get_attribute("name")=="activationCode":
i.send_keys(code)
found=True
if found and i.get_attribute("value")=="Get Started":
i.click()
break
except:
print('\33[91m'+'INVALID LOGIN CREDENTIALS'+'\033[0m')
exit()
time.sleep(5)
try:
for i in driver.find_elements_by_tag_name("input"):
if i.get_attribute("value")=="Continue":
i.click()
break
except:
print('\33[91m'+'INVALID TEST CODE'+'\033[0m')
exit()
time.sleep(5)
ids = 0
for i in driver.find_elements_by_tag_name("a"):
if i.get_attribute("id")[:2]=="id":
ids+=1
for cnt in range(1,ids+1):
options=[]
for i in driver.find_elements_by_tag_name("input"):
if i.get_attribute("id")=="ch"+str(cnt):
options.append(i)
button=random.choice(options)
button.click()
if cnt!=ids:
driver.find_element_by_id("id_"+str(cnt+1)).click()
time.sleep(delay)
for i in driver.find_elements_by_tag_name("input"):
if i.get_attribute("id")=="sub":
i.click()
break
time.sleep(7)
alert_obj2 = driver.switch_to.alert
time.sleep(7)
alert_obj2.accept()