your code looks odd. typically, you locate an element, and then do actions with it... rather than locating it each time.

try something like this:

from selenium import webdriver

driver = webdriver.Firefox()
elem = driver.find_element_by_name('j_username')
elem.clear()
elem.send_keys('username')
Answer from Corey Goldberg on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › send_keys-element-method-selenium-python
send_keys() element method - Selenium Python - GeeksforGeeks
July 12, 2025 - # import webdriver from selenium import webdriver # create webdriver object driver = webdriver.Firefox() # get geeksforgeeks.org driver.get("https://www.geeksforgeeks.org/") # get element element = driver.find_element_by_id("gsc-i-id2") # send keys element.send_keys("Arrays")
🌐
Selenium
selenium.dev › documentation › webdriver › actions_api › keyboard
Keyboard actions | Selenium
July 29, 2025 - Keys.COMMAND : Keys.CONTROL; WebElement textField = driver.findElement(By.id("textInput")); new Actions(driver) .sendKeys(textField, "Selenium!") .sendKeys(Keys.ARROW_LEFT) .keyDown(Keys.SHIFT) .sendKeys(Keys.ARROW_UP) .keyUp(Keys.SHIFT) .keyDown(cmdCtrl) .sendKeys("xvv") .keyUp(cmdCtrl) .perform(); Assertions.assertEquals("SeleniumSelenium!", textField.getAttribute("value")); } } ActionChains(driver)\ .send_keys("abc")\ .perform()
Discussions

selenium webdriver sendkeys() using python and firefox - Stack Overflow
After changing my selenium version the test was able to send_keys() and submit the form using send_keys(Key.ENTER) More on stackoverflow.com
🌐 stackoverflow.com
python - Selenium - send keys - what element should I use - Stack Overflow
from selenium import webdriver from selenium.webdriver.common.keys import Keys driver=webdriver.Chrome() driver.get("site_name") driver.find_element_by_xpath('//body').send_keys(Keys.CONTROL+Keys.END) ... Sign up to request clarification or add additional context in comments. ... A simple javascript should be sufficient as well. Python ... More on stackoverflow.com
🌐 stackoverflow.com
To send threekeys using send_keys() in selenium python webdriver - Stack Overflow
I am trying to type a float number into a textbox with default value 0.00.But it tries to get appended instead of overwriting it.I tried with .clear() and then send_keys('123.00') but still it gets More on stackoverflow.com
🌐 stackoverflow.com
How to send keys with python selenium after an element has loaded? - Stack Overflow
Here I made an attempt of using ... before sending the keys. ... File "/home/wit/PycharmProjects/gmeet-automation/main.py", line 20, in username = driver.find_element(By.ID, 'identifierId') File "/home/wit/PycharmProjects/gmeet-automation/venv/git/google-meet-project/lib/python3.10/site-packages/selenium/webdriver... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

What is the alternative to SendKeys in Selenium?
An alternative to SendKeys in Selenium is to use JavaScriptExecutor to set the value of an input field directly. This method is useful when sendKeys is too slow or fails to input text. Use “js.executeScript("arguments[0].value='text';", element)” to achieve this.
🌐
theknowledgeacademy.com
theknowledgeacademy.com › blog › selenium-send-keys
Selenium SendKeys: Automating Text Input in Web Testing
How to use XPath in Selenium?
XPath in Selenium is utilised for navigating through the HTML structure of a webpage to find elements. It’s a query language for selecting nodes from an XML document. Use “driver.findElement(By.xpath("your_xpath"))” to locate elements using either absolute or relative XPath expressions
🌐
theknowledgeacademy.com
theknowledgeacademy.com › blog › selenium-send-keys
Selenium SendKeys: Automating Text Input in Web Testing
What is the Knowledge Pass, and how does it work?
The Knowledge Academy’s Knowledge Pass, a prepaid voucher, adds another layer of flexibility, allowing course bookings over a 12-month period. Join us on a journey where education knows no bounds.
🌐
theknowledgeacademy.com
theknowledgeacademy.com › blog › selenium-send-keys
Selenium SendKeys: Automating Text Input in Web Testing
🌐
Selenium Python
selenium-python.readthedocs.io › getting-started.html
2. Getting Started — Selenium Python Bindings 2 documentation
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By driver = webdriver.Firefox() driver.get("http://www.python.org") assert "Python" in driver.title elem = driver.find_element(By.NAME, "q") elem.clear() elem.send_keys("pycon") elem.send_keys(Keys.RETURN) assert "No results found." not in driver.page_source driver.close()
🌐
Testsigma
testsigma.com › blog › test automation › selenium sendkeys: a detailed usage guide
Selenium SendKeys: A Detailed Usage Guide
June 28, 2025 - Sendkeys Method: Once you have selected the element, you can use the sendkeys method to send data as input to the element. This method takes in a string argument representing the data you want to enter, and simulates the typing of a keyboard ...
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › selenium-send-keys
Selenium SendKeys: Automating Text Input in Web Testing
This program navigates to a page you wish to test in Selenium. Next, it uses an element locator find_element_by_name() to find the field you wish to test on the page. Once the input field has been retrieved, the send_keys() function will allow you to give inputs to test the input fields...
🌐
Testim
testim.io › blog › selenium-sendkeys
Selenium SendKeys: A Detailed Usage Guide With Examples
November 1, 2024 - And finally, I will give you some sample Python and Java code that uses the sendKeys method. SendKeys is a method used to send keyboard input such as characters, numbers, and symbols to text boxes inside an application.
Find elsewhere
🌐
Medium
medium.com › @aarhar › selenium-in-python-keyboard-text-inputs-51901b46b7d0
Selenium in Python — Keyboard & Text Inputs | Medium
July 4, 2023 - Now instead of clicking, we can directly input keys to this element using Selenium’s ‘.send_keys()’ method.
🌐
Python Basics
pythonbasics.org › selenium-keyboard
selenium keyboard - Python Tutorial
The selenium webdriver starts the ... have a unique id). We grab the html element by its unique identifier like this: Then the method .send_keys() is used to type into the element....
🌐
Bird Eats Bug
birdeatsbug.com › blog › selenium-python-press-enter
How to Press Enter in Selenium Python: Complete Guide | Bug Tracking Blog @ Bird Eats Bug
October 6, 2025 - In Selenium Python, pressing Enter is required when testing workflows like submitting login forms, running inline searches, or confirming entries in modal windows. Since many of these actions depend on JavaScript events, handling Enter incorrectly ...
🌐
TutorialsPoint
tutorialspoint.com › article › send-keys-without-specifying-element-in-python-selenium-webdriver
Send keys without specifying element in Python Selenium webdriver
from selenium import webdriver #set geckodriver.exe path driver = webdriver.Firefox(executable_path="C:\geckodriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/index.htm") #identify element with tagname l = driver.find_element_by_tag_name("input") l.send_keys("Selenium") #obtain value obtained print("Value entered: ") print(l.get_attribute('value')) driver.quit()
🌐
BrowserStack
browserstack.com › home › guide › sendkeys in selenium webdriver
SendKeys in Selenium WebDriver | BrowserStack
December 31, 2024 - In the above code snippet, we use id as a locator to locate both fields. Once the script is executed, it will automatically detect both the input fields and fill the data as defined in the selenium sendKeys() method.
🌐
GitHub
gist.github.com › baijum › 1047207 › 350bf70d95865e96ea8894449da58ccc2e775411
Selenium with Python · GitHub
February 5, 2022 - Next we are sending keys, this is similar to entering keys using your keyboard. Special keys can be send using Keys class imported from selenium.webdriver.common.keys:
🌐
TutorialsPoint
tutorialspoint.com › how-do-i-send-a-delete-keystroke-to-a-text-field-using-selenium-with-python
How do I send a DELETE keystroke to a text field using Selenium with Python?
February 2, 2021 - l = driver.find_element_by_id("gsc−i−id1") l.send_keys("Sel") l.send_keys(Keys.CONTROL + 'a', Keys.BACKSPACE) Also, to use the Keys class, we have to add the import statement from selenium.webdriver.common.keys import Keys in our code.
🌐
Apidog
apidog.com › blog › send-keys-delay-in-selenium
How to Send Keys with Delay in Selenium (Easy Guide)
February 3, 2026 - There are several approaches to implementing delayed send keys in Selenium. We'll cover the most common and effective methods, starting with the simplest and progressing to more advanced techniques. The most straightforward method involves using a simple loop and Python's time.sleep() function.
🌐
Stack Overflow
stackoverflow.com › questions › 70422287 › how-to-send-keys-with-python-selenium-after-an-element-has-loaded
How to send keys with python selenium after an element has loaded? - Stack Overflow
Here I made an attempt of using the WebDriverWait function to allow time for the text box to be loaded before sending the keys. ... File "/home/wit/PycharmProjects/gmeet-automation/main.py", line 20, in <module> username = driver.find_element(By.ID, 'identifierId') File "/home/wit/PycharmProjects/gmeet-automation/venv/git/google-meet-project/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 1244, in find_element return self.execute(Command.FIND_ELEMENT, { File "/home/wit/PycharmProjects/gmeet-automation/venv/git/google-meet-project/lib/python3.10/site-packages/selenium
🌐
TutorialsPoint
tutorialspoint.com › typing-enter-return-key-in-selenium
Typing Enter/Return key in Selenium.
We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys. ENTER as an argument to the method. Also, we can use pass Keys. RETURN as an argument to the sendKeys method for the same purpose.