r/pythonhelp • u/[deleted] • Mar 20 '23
Form Automation using Selenium
Please help me with the form automation using Selenium in Python. I have tried every possible way to enter the xpath, and also tried suggestions from previous stackoverflow answers to get the xpath but nothing seems to work. The script is unable to locate the element using the xpath. Here is the form link that I am trying to automate: https://shooliniuniversity.com/how-to-apply .
Here is my code:
from selenium import webdriver
import time
# create webdriver object
driver = webdriver.Chrome()
# navigate to the form
driver.get("https://shooliniuniversity.com/how-to-apply")
driver.maximize_window()
time.sleep(5)
# fill the form
Name = driver.find_element("xpath", '//*[@id="registerForm"]/div[2]/div[12]')
Name.send_keys('John Doe')
# submit the form
# submit_button = driver.find_element("xpath", '//*[@id="wpcf7-f300-o1"]/form/p[9]/input')
# submit_button.click()
# time.sleep(5)
# close the browser
# driver.quit()