-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot.py
66 lines (51 loc) · 2.42 KB
/
bot.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
from selenium import webdriver
import time
class init_bot():
# Init function only initializes the the driver instance.
def __init__(self):
path_to_edge_driver = 'C:\\Users\\Ashish\\Desktop\\Codes For Fun\\Py Automation\\edgedriver_win64\\msedgedriver.exe'
self.driver = webdriver.Edge(path_to_edge_driver)
class fetch_responses(init_bot):
def select_yes(self):
driver = self.driver
url = 'https://docs.google.com/forms/d/e/1FAIpQLSelUSzWllrU9H7ML30XtU3ghBYMdZYKMjXZo4sXwQxxpiJVIA/viewform'
driver.get(url)
driver.implicitly_wait(5)
driver.find_element_by_xpath("//*[contains(text(), 'Yes')]").click()
time.sleep(3)
driver.find_element_by_xpath("//*[contains(text(), 'Hell Yea!')]").click()
time.sleep(3)
driver.find_element_by_xpath("//*[contains(text(), 'Submit')]").click()
driver.quit()
# driver.find_element_by_xpath("//*[contains(text(), 'Submit another response')]").click()
def select_no(self):
driver = self.driver
url = 'https://docs.google.com/forms/d/e/1FAIpQLSelUSzWllrU9H7ML30XtU3ghBYMdZYKMjXZo4sXwQxxpiJVIA/viewform'
driver.get(url)
driver.implicitly_wait(5)
driver.find_element_by_xpath("//*[contains(text(), 'No'").click()
time.sleep(3)
driver.find_element_by_xpath("//*[contains(text(), 'No.')]").click()
time.sleep(3)
driver.find_element_by_xpath("//*[contains(text(), 'Submit')]").click()
driver.quit()
# driver.find_element_by_xpath("//*[contains(text(), 'Submit another response')]").click()
def select_no_pref(self):
driver = self.driver
url = 'https://docs.google.com/forms/d/e/1FAIpQLSelUSzWllrU9H7ML30XtU3ghBYMdZYKMjXZo4sXwQxxpiJVIA/viewform'
driver.get(url)
driver.implicitly_wait(5)
driver.find_element_by_xpath("//*[contains(text(), 'No Preference.')]").click()
time.sleep(3)
driver.find_element_by_xpath("//*[contains(text(), 'No Preference.')]").click()
time.sleep(3)
driver.find_element_by_xpath("//*[contains(text(), 'Submit')]").click()
# driver.implicitly_wait(10)
driver.quit()
if __name__ == '__main__':
for i in range(20):
bot = fetch_responses()
bot.select_yes()
bot.select_no()
bot.select_no_pref()
print(i)