Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- from selenium import webdriver
- chromedriver = "C:/Users/woofe/Downloads/chromedriver_win32/chromedriver"
- driver = webdriver.Chrome(chromedriver)
- link = 'https://docs.google.com/forms/d/e/1FAIpQLSd7EiSdvEcPsbRYDU5-6niPu6TNisS27murJEKCyX59EJ_1GQ/viewform'
- driver.get(link)
- xps = '//*[@id="mG61Hd"]/div/div[2]/div[2]/div['
- xpm = ']/div/div[2]/div/content/div/div['
- xpe = ']/label/div/div[1]/div[3]/div'
- submit_xp = '//*[@id="mG61Hd"]/div/div[2]/div[3]/div/div/div/content/span'
- another_xp = '/html/body/div[1]/div[2]/div[1]/div[2]/div[3]/a'
- code = "//*[@id=\"mG61Hd\"]/div/div[2]/div[2]/div[6]/div/div[1]/div/div/div"
- maxnum = [4, 2, 2, 2, 3] # number of choice for each questions
- counter = 0
- nqT = len(maxnum)
- while 1:
- num_ans = []
- for i in range(0, len(maxnum)):
- num_ans.append(random.randint(1, maxnum[i]))
- driver.get(link)
- for i in range(1, nqT + 1):
- x_p = xps + str(i) + xpm + str(num_ans[i - 1]) + xpe
- d = driver.find_element_by_xpath(x_p)
- d.click()
- # time.sleep(random.randint(1,2))
- # change the speed of clicking by reducing sleep time
- time.sleep(0.5)
- raw_parse = driver.find_elements_by_class_name("freebirdFormviewerViewItemsItemItemTitle")
- full_parse = raw_parse[5].text
- parse_list = full_parse.split(" ")
- required_string = parse_list[2]
- form = driver.find_element_by_class_name("quantumWizTextinputPaperinputInput")
- form.send_keys(required_string)
- submit = driver.find_element_by_xpath(submit_xp)
- submit.click()
- counter = counter + 1
- print(counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement