How many options of each part in GoogleForm?


How many options of each part in GoogleForm?



I have a Google Form with Multiple-choice questions only.
I want to count the number of options of each question in it by python + selenium.
How can i do that ?
Please help me!


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()





See How to Ask. What have you tried? What research have you done? Question work best here if you show some code that illustrates the problem.
– jdv
Jun 29 at 17:00





this is the first time i use Stackoverflow. I am writing an autofil GoogleForm bot with python and selenium, but i have to count the numbers of options of each question manually. and i am stuck when i try to count automatically :((
– HTV98
Jun 29 at 17:02






You might want to take the tour then. The idea is that you ask specific questions about code you have written. Tell us what you want to do, show what you have tried, and tell us what result you get.
– jdv
Jun 29 at 17:03






I am writing an autofil GoogleForm bot with python and selenium, but i have to count the numbers of options of each question manually. and i am stuck when i try to count automatically
– HTV98
Jun 29 at 17:09





i have edited my question! <3
– HTV98
Jun 29 at 17:15









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV