Automated test example in Java with Cucumber and Selenium WebDriver
This project is an example of UI automated functional test for Google home page and search using Selenium and Cucumber.
Test scenarios are described in the feature files located here ./src/test/resources/com/automatedtest/sample.
For more info about this project, read the article "UI automated test project example with Selenium, Cucumber and Java"
Installation
You need to have Java 8 JDK installed along with maven.
To run the tests locally with Chrome, install ChromeDriver from here, add its location to your system PATH and add webdriver.chrome.driver=path/to/the/driver to your local variables.
To run the tests locally with Firefox, install GeckoDriver from here and add its location to your system PATH.
To install all dependencies, run
$ mvn clean install
Running tests
$ mvn test
By default, tests will run on Chrome. To change that, specify -Dbrowser={browser}
where {browser}
is either chrome
or firefox
. If you haven't added the chrome driver path to your local variables, you can add it directly in the run command with the option -Dwebdriver.chrome.driver=path/to/the/driver
.
You can also select specific scenarios to execute using -Dcucumber.options="--tags @your_tag"
. More info about tags and how to combine them here.