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:

Output:

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:

Output:

Click button in selenium


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

 

Print Friendly, PDF & Email
Select random value in the Weblist
Work with multiple browser windows
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

Leave a Reply

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