selenium textbox

Given a webpage containing a text area or text field, text can be automatically written using Python code. In this article we will demonstrate this automation using a small code snippet.

Related course
Selenium WebDriver and Python: WebTest Automation Course

Selenium add textbox text
We start by importing the selenium module. The driver needs to be created starting the web browser. We open the target website using the method


We select the html element using the method


Then we write text in the box using the method:


Complete code:

from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.binary_location = "/usr/bin/chromium"
driver = webdriver.Chrome(chrome_options=options)
text_area = driver.find_element_by_id('textarea')
text_area.send_keys("This text is send using Python code.")

The browser will start automatically adding the text:

selenium textbox
send_keys method writes in textbox