-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomate_forms.py
58 lines (35 loc) · 1.57 KB
/
automate_forms.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
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Storing the values in the list
name = ['Maximus', 'Dhadharey']
email = ['maximus33@gmail.com', 'dhaddharey33@gmail.com']
age = [22, 21]
# XPath URL
inputName = '//*[@id="mG61Hd"]/div/div[2]/div[2]/div[1]/div/div[2]/div/div[1]/div/div[1]/input'
inputEmailID = '//*[@id="mG61Hd"]/div/div[2]/div[2]/div[2]/div/div[2]/div/div[1]/div/div[1]/input'
inputAge = '//*[@id="mG61Hd"]/div/div[2]/div[2]/div[3]/div/div[2]/div/div[1]/div/div[1]/input'
# Radion Buttons ['Student', 'Enginner', 'Entrepreneur', 'IT Professional', 'Policy maker', 'Social worker', 'Teachers', 'Journalist', 'Freelancer', 'others']
radioStudent = '//*[@id="mG61Hd"]/div/div[2]/div[2]/div[4]/div/div[2]/div/span/div/div[1]/label/div/div[1]'
# Submit Buttons
submit = '//*[@id="mG61Hd"]/div/div[2]/div[3]/div[1]/div/div/span'
def sleep():
time.sleep(3)
browser = webdriver.Firefox()
browser.get('https://docs.google.com/forms/d/11agBkil4mX-ZHmlq-ILaBUqyy1jH_yfSHELm6FZfbVc/viewform?edit_requested=true')
# Implement the for loop in the list data type
i = 0
while i < len(name):
browser.find_element_by_xpath(inputName).send_keys(name[i])
browser.find_element_by_xpath(inputEmailID).send_keys(email[i])
browser.find_element_by_xpath(inputAge).send_keys(age[i])
browser.find_element_by_xpath(radioStudent).click()
sleep()
browser.find_element_by_xpath(submit).click()
i += 1
sleep()
browser.back()
sleep()
#Finish the loop here
# Quit browser
browser.quit()