-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_automation_ipynb
47 lines (32 loc) · 1.31 KB
/
form_automation_ipynb
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
#referring to this website
#https://medium.com/swlh/automatically-filling-multiple-responses-into-a-google-form-with-selenium-and-python-176340c5220d
!apt update
!apt install chromium-chromedriver
!apt install chromium-browser
!apt install -y python3-pyvirtualdisplay
!apt upgrade
!pip install selenium
from selenium import webdriver
from pyvirtualdisplay import Display
import time
option = webdriver.ChromeOptions()
option.add_argument("--headless")
option.add_argument("--disable-gpu")
option.add_argument('--no-sandbox')
chromedriver_location = "/usr/bin/chromedriver"
driver = webdriver.Chrome(chromedriver_location,options=option)
driver.get("your_form_link")
radiobuttons = driver.find_elements_by_class_name("docssharedWizToggleLabeledLabelWrapper")
submitbutton = driver.find_element_by_class_name("appsMaterialWizButtonPaperbuttonContent")
print("class found successfully")
#https://www.kite.com/python/answers/how-to-get-the-indices-of-all-occurrences-of-an-element-in-a-list-in-python
#to find the indexes of the data that you want to input in
print ("The list is : " + str(radiobuttons))
counter = 0
for i in radiobuttons:
counter = counter + 1
print ("Length of list using naive method is : " + str(counter))
radiobuttons[1].click()
radiobuttons[3].click()
submitbutton.click()
print("process done successfully")