Enter in selenium using sendkeys

Enter using SendKeys

During the execution sometimes we have to press enter you can do it easily in the Selenium by using the sendkeys. take a scenario where you are to enter text into the textbox and that text is getting saved only when you are pressing enter so in this now you have to use sendkeys first and then you to press enter so you can do it easily first you have to use sendkeys for entering the text and then you have to use sendkeys for pressing the enter in both the line of code the xpath of the element with the same as we have to press enter on the same textbox

You can perform different keyboard operations using sendkeys in the below table you can see Keyboard action and there use with help of Selenium sendkeys there are other classes as well in Selenium for keyboard events and mouse events but the preferred method will be sendkeys because it is very easy to use you don’t need to call some different class inside your test scripts.

Table for sendkeys command

Keyboard's Key Keys values
Arrow Key - Down
Arrow Key - Up
Enter Key
Shift Key
Esc Key

so in the above table I have given some example that how you can perform keyboard elements using the Selenium sendkeys you can perform enter , esc , Tab etc

In below example we can see I have used sendkeys for pressing the enter button of the keyboard. in the same way you can use different keys by using about table I am not covered all the keys in above table you can explore more by doing hands-on in the eclipse in your system and please let let me know in the comment section below

sendkeys selenium

Using sendkeys you can perform different operations as well to check please go to this link Sendkeys in Selenium WebDriver

Author: Saad Mansuri

Leave a Reply

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