-
Notifications
You must be signed in to change notification settings - Fork 1
/
selenium_script.py
107 lines (79 loc) · 3.49 KB
/
selenium_script.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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import time
def main():
url = 'https://webapps.cs.moravian.edu/'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(1)
Select(driver.find_element(By.ID, 'quiz_location')).select_by_value('Home')
time.sleep(1)
def get_gold():
driver.find_element(By.ID, 'start_button').click()
time.sleep(1)
for i in range(1, 6):
print("Block: ", i)
driver.find_element("css selector", "input[name='answer'][id='4']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerB'][id='3']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerC'][id='2']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerD'][id='1']").click()
time.sleep(1)
driver.find_element(By.ID, 'submit_button').click()
time.sleep(3)
print(driver.find_element(By.ID, 'user_result').text)
def get_green():
driver.find_element(By.ID, 'start_button').click()
time.sleep(1)
for i in range(1, 6):
print("Block: ", i)
driver.find_element("css selector", "input[name='answer'][id='1']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerB'][id='2']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerC'][id='3']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerD'][id='4']").click()
time.sleep(1)
driver.find_element(By.ID, 'submit_button').click()
time.sleep(3)
print(driver.find_element(By.ID, 'user_result').text)
def get_orange():
driver.find_element(By.ID, 'start_button').click()
time.sleep(1)
for i in range(1, 6):
print("Block: ", i)
driver.find_element("css selector", "input[name='answer'][id='2']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerB'][id='1']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerC'][id='4']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerD'][id='3']").click()
time.sleep(1)
driver.find_element(By.ID, 'submit_button').click()
time.sleep(3)
print(driver.find_element(By.ID, 'user_result').text)
def get_blue():
driver.find_element(By.ID, 'start_button').click()
time.sleep(1)
for i in range(1, 6):
print("Block: ", i)
driver.find_element("css selector", "input[name='answer'][id='3']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerB'][id='4']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerC'][id='1']").click()
time.sleep(0.5)
driver.find_element("css selector", "input[name='answerD'][id='2']").click()
time.sleep(1)
driver.find_element(By.ID, 'submit_button').click()
time.sleep(3)
print(driver.find_element(By.ID, 'user_result').text)
get_orange()
driver.quit()
if __name__ == '__main__':
main()