У меня есть форма Google только с несколькими вариантами ответов.
Я хочу посчитать количество вариантов каждого вопроса в нем по python + selenium.
Как я могу это сделать ?
Пожалуйста, помогите мне!
import time
import random
from selenium import webdriver
#driver
chromeDriver = "D:/AppMadeByMe/googleform/chromedriver"
driver = webdriver.Chrome(chromeDriver)
linkForm = 'https://docs.google.com/forms/d/e/1FAIpQLSc_aGBHkJfoDMxX9cy1wU9lV2bWsdcIx3m05jT64XYNNu24cw/viewform'
driver.get(linkForm)
#Xpath - get the unchange part's XPATH
xpRigth = '//*[@id="mG61Hd"]/div/div[2]/div[2]/div['
xpMid = ']/div[2]/div/content/div/label['
xpLeft = ']/div/div[1]/div[3]/div'
xpSubmit = '//*[@id="mG61Hd"]/div/div[2]/div[3]/div/div/div/content/span'
xpResubmit = '/html/body/div/div[2]/div[1]/div[2]/div[3]/a'
#count number of questions
optionmaxNum = [3,4,3,4,2] #number answers of each questions
num_ans = []
lenOption = len(optionmaxNum)
count = 0
while(count < 100):
count += 1
for i in range(0,lenOption):
num_ans.append(random.randint(1,optionmaxNum[i]))
for i in range(1,lenOption+1):
xp = xpRigth + str(i) + xpMid + str(num_ans[i-1]) + xpLeft
d = driver.find_element_by_xpath(xp)
d.click()
time.sleep(0.1)
num_ans = []
submit = driver.find_element_by_xpath(xpSubmit)
submit.click()
time.sleep(0.5)
resub = driver.find_element_by_xpath(xpResubmit)
resub.click()