Pick date in google form with selenium


so I try to make a bot using selenium in python and I stuck in date form here the code

from selenium import webdriver
from selenium.webdriver import ActionChains
import time

driver = webdriver.Chrome()
driver.maximize_window() # For maximizing window
driver.implicitly_wait(20) # gives an implicit wait for 20 seconds
website = driver.get("https://forms.gle/VUwbshGuXxDb7NRbA")
tanggal = driver.find_element_by_xpath("//*[@id="mG61Hd"]/div[2]/div/div[2]/div/div/div/div[2]/div/div/div[2]/div[1]/div/div[1]/input").send_keys("12")

I already tried using click() and send_keys() but it won’t work


  1. Use explicit waits.
  2. I could update the date with the help of JS setAttribute.
  3. Date format is yyyy-mm-dd

Code :

from datetime import datetime
today_date = datetime.today().strftime('%Y-%m-%d')

driver = webdriver.Chrome(driver_path)
wait = WebDriverWait(driver, 30)
driver = webdriver.Chrome(driver_path)
wait = WebDriverWait(driver, 30)
date= wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.quantumWizTextinputPaperinputInput")))
driver.execute_script(f"arguments[0].setAttribute('value', '{today_date}')", date)

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

Answered By – cruisepandey

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published