How to locate and insert a value in a text box (input) using Python Selenium?

How to locate and insert a value in a text box (input) using Python Selenium?

Assuming your page is available under http://example.com

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get(http://example.com)

Select element by id:

inputElement = driver.find_element_by_id(a1)
inputElement.send_keys(1)

Now you can simulate hitting ENTER:

inputElement.send_keys(Keys.ENTER)

or if it is a form you can submit:

inputElement.submit() 

How to locate and insert a value in a text box (input) using Python Selenium?

Leave a Reply

Your email address will not be published. Required fields are marked *