Selenium automation is not just about navigating and clicking through the links. Yes, you can use it to switch tabs, find broken links, or even drag and drop directly. But there is a lot more to it. An essential aspect of test automation is passing values to the text fields. In this article, we’ll delve into how Selenium helps us pass values to text fields using the Selenium sendKeys() method. Let us start on our journey to learn how to sendkeys in Selenium.
What Is Selenium sendKeys() Method?
Selenium provides sendKeys() method to input content in editable text fields or password fields in a webpage. These fields are like the typical web elements present on the web page that can be identified using any of the Selenium locators. You can refer to our article on Selenium locators to learn more about the different locators you can use.
Let us understand the utility of the sendKeys() method through an example. Consider the below use-case: