Slenium sample code using eclipse and java

Let’s see how we can guide selenium to work on a web application,As we come to know from our old posts, selenium identifies elements (WebElement) on basis of the html tags and their attributes.

Let’s take the mercury tour application as our AUT(application under test) and firefox browser,
For other browsers like IE and Chrome, please refer working with multiple browsers.



Register and check if the user name and password is correct to log in the site.


  • Go to the url
  • Click on the register link
  • Enter required data to register site
  • Go to home page
  • Enter the username and password and click on the submit button.
  • Verify if logged in

Create a new class as mentioned in the eclipse setup for selenium

and paste below code to run.

Note – 

For each code line below, have comments to understand the need for that line.


Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

1 Response

  1. June 7, 2016

    […] To import any other .jar files later time, follow step 8. Now you are in a good shape to write a simple selenium test using eclipse IDE with Java language. Read selenium sample test in java […]

Leave a Reply

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