How to write Web automated tests — Selenium (3/7)

Photo by Eric Krull — Unsplash

Add Selenium dependencies

First of all, add selenium dependencies to the pom.xml file:

Download gecko and chrome drivers

Download chromedriver from here and geckodriver from here. Place all drivers in the drivers folder:

Implement Driver Manager

Create package client and package web inside. Then create class SeleniumDriverManager with the code below:

Drive properties initialization

If you use CI agents, parameters webdriver.chrome.driver and webdriver.gecko.driver can be already configured. Check agent description before using.

Add feature file

Add web subpackage to the features package and create duck_test.feature file:

Add glue code

Create WebSteps inside steps package and add code below:

Execute the tests

The final version of the execution tool after all manipulation is stored here:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store