The Selenium Java Framework is a good starting point for writing your UI automated tests utilizing Java, Selenium and Zalenium for running the tests in a CI manner.
Tests can be configured to run against different domains. For example: https://www.some-site.de and https://www.some-site.fr.
Similar as for multiple domains the tests can also be run on multiple environments, for example a staging and a live environment. It is as simple as changing a spring profile parameter.
Page content can be validated with different languages through a config file.
Handling user data within a json file where the appropriate user will be determined by country.
The option to run the tests in headless mode (without opening a browser).
Zalenium is a Selenium Grid extension to scale your local grid dynamically with docker containers.
Allure Framework is a flexible lightweight multi-language test report tool that shows a very concise representation of what has been tested in a neat web report form
The framework has the ability to run multiple tests in parallel. Setting this up just requires to set the thread-count
paramenter in testng.xml
.
- Java 8
- Maven
- Spring Boot
- TestNG
- Allure
- Zalenium
To run the tests on your local machine use the command:
mvn clean test -Dspring.profiles.active=live -Dcountry=com -Dbrowser=chrome
The parameters explained:
spring.profiles.active
- defines on which environment the tests will runcountry
- defines on which domain the tests will runbrowser
- defines the browser (chrome/firefox
)
To be able to run the tests on Zalenium (which is basically just a dockerized Selenium Grid), first Zalenium has to be started.
# Pull docker-selenium
docker pull elgalu/selenium
# Pull Zalenium
docker pull dosel/zalenium
docker run --rm -ti --name zalenium -p 4444:4444 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/videos:/home/seluser/videos \
--privileged dosel/zalenium start
After Zalenium is running just the browser parameter has to be changed in order to run the tests
mvn clean test -Dspring.profiles.active=live -Dcountry=com -Dbrowser=zalenium
The latest versions of the Chrome and Firefox browsers have the feature to run browsers in headless mode. This speeds up the running time of the tests immensely. For running the tests using the headlless mode feature:
mvn clean test -Dspring.profiles.active=live -Dcountry=com -Dbrowser=chrome -Dmode=headless
where as browser either chrome
or firefox
can be selected.
Currently the tests are configured to run just on MacOS. But this can be changed here , the relative path just has to be replaced with the appropriate driver for that OS.
Reporting of the tests results is one of the most important aspects of a framework. It doesn't matter how many and good your tests are when they are not enough visible. In this framework Allure was used to generate visually rich and insightful reports.
Allure has to be installed before being able to show test results:
$ brew untap qameta/allure
$ brew update
$ brew install allure
After every test run the results are automatically stored in an allure-results
directory. The results then can be seen locally by running:
allure serve
or in all popular CI's with the help of allure plugins.
Open a github issue or for suggestions a Pull Request straight away.