Enter text in a edit box and click on a button

In the previous post, we have seen how to select the random value in a WebList. In this post, we will see how to enter text in a edit box and click on a button.

Enter text into a Edit box:

In our demo application, we have 2 edit boxes ‘First Name’ and ‘Last Name’. Suppose, we need to enter the data into these edit boxes. We have to use the method ‘sendKeys‘ to enter the data.

Edit boxes

Code for entering data in first name and last name:


Enter data with selenium



Click on a button :

We need to create an object of button by using any locator like id, xpath etc. Then, use the method click() to click on that button.

In our application, we have a ‘Submit’ button. When we click on that button, it gives a message ‘Form is submitted’.

To identify button , we use xpath ‘//*[@id=’bttn’]‘.

Code to click on Submit button:


Click button in selenium

Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum


Select random value in the Weblist
Work with multiple browser windows
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

Leave a Reply

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