cover Image

What is selenium?

Selenium is a widely used test automation framework. There are 3 selenium tools; Selenium RC, Selenium IDE and Selenium Webdriver, out of which the Selenium Webdriver is the most commonly used industry tool. Using the Selenium Webdriver the test cases can be automated with Java.

To learn more about selenium, follow the link below: https://www.seleniumhq.org/docs/01_introducing_selenium.jsp#introducing-selenium

Environment Setup

First you need to install java to the PC. Then the Eclipse IDE needs to be installed. Next the Selenium Webdriver for Java must be downloaded.

https://www.seleniumhq.org/download/

Example

Step 1 : Create a new project.

a. Open Eclipse and go on to the File tab and click on New.Then select Java project.

First Image

b. Give your project name and then click Finish.

Second Image

Newly created project will display in eclipse project explorer)

Step 2 : Create a Package

a. Right click on the created project and go New.Then click on Package.

Third Image

b. Give your package name and click on Finish.

Fourth Image

(Newly created package display under the created project)

Step 3 : Create new Java Class

a. Right click on the created package and go New.Then click on Java Class.

Fifth Image

(Newly created class display under the created package)

Step 4 : Add Selenium jars to the Project.

a. Right-click on Project and Select Properties then Java build path. Then navigate to Libraries tab and click Add External JARs.

sixth Image

b. Add Selenium Java jar source file.

seventh Image

c. Add all the jars from the libs folder.

eighth Image

d. Click Apply and then OK.

tenth Image

Step 5 : Write test Script

For example, the following test will direct you to the Antler Group website.the following steps are included in the script,

  • Launch the Chrome browser
  • Open website “Antlergroup.com”
  • Print a Message to display that the website is opened successfully
  • Wait for 5 Seconds
  • Close the Browser

leventh Image

Go to the Home Page