透過Selenium 完成Google Form 自動填寫

from selenium import webdriver
import random
from datetime import datetime
year = datetime.now().year
month = datetime.now().month
day = datetime.now().day
driver = webdriver.Edge(‘C:/WebDriver/bin/msedgedriver’)
driver.get(‘https://docs.google.com/…’)
date_check = driver.find_elements_by_xpath(“//div[contains(@class,’quantumWizTextinputPaperinputContentArea exportContentArea’)]//input”)[0]
date_check.send_keys(year, month, day)
position_Check = driver.find_element_by_xpath(“//div[@class=’appsMaterialWizToggleRadiogroupEl exportToggleEl’ and @id=’i12']”)
position_Check.click()
code_check = driver.find_elements_by_xpath(“//div[contains(@class,’quantumWizTextinputPaperinputContentArea exportContentArea’)]//input”)[1]
code_check.send_keys(‘XXXXX’)
name_check = driver.find_elements_by_xpath(“//div[contains(@class,’quantumWizTextinputPaperinputContentArea exportContentArea’)]//input”)[2]
name_check.send_keys(‘XXX’)
travel_Check = driver.find_element_by_xpath(
“//div[@class=’appsMaterialWizToggleRadiogroupEl exportToggleEl’ and @id=’i51']”)
travel_Check.click()
contact_Check = driver.find_element_by_xpath(“//div[@class=’appsMaterialWizToggleRadiogroupEl exportToggleEl’ and @id=’i65']”)
contact_Check.click()
temeprature = str(round(random.uniform(35.8, 37), 1))
temperature_check = driver.find_elements_by_xpath(“//div[contains(@class,’quantumWizTextinputPaperinputContentArea exportContentArea’)]//input”)[5]
temperature_check.send_keys(temeprature)
submit = driver.find_elements_by_xpath(“//div[@role=’button’]”)[0]
submit.click()
driver.close()

--

--

--

Continuous Quality improvement for Life and Work

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
CQI365

CQI365

Continuous Quality improvement for Life and Work

More from Medium

Authenticating and Interacting with Google Drive

Creating a Recognition Code From Scratch

How To Create a Self-Signed SSL Certificate for Apache in Ubuntu Virtual Cloud Server

OpenCV Basic example