Wednesday, October 27, 2021

selenium 3 fill input


form default input value Jone Doe

automate testing fills in chuan shuo

submit button click is automated
#main.py

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

os.environ['PATH'] += r"C:/Users/zchen/PycharmProjects/selenium"
driver = webdriver.Chrome()
driver.get("https://www.w3schools.com/html/html_forms.asp")
driver.implicitly_wait(30)

firstName = driver.find_element(By.ID, 'fname')
lastName = driver.find_element(By.ID, 'lname')

firstName.clear()
firstName.send_keys('chuan')
lastName.clear()
lastName.send_keys('shuo')

submitButton = driver.find_element(By.XPATH, "//input[@type='submit' and @value='Submit']")
submitButton.click()

reference:

find submit button

No comments:

Post a Comment