Dockerized Java automated tests for WEB application
1.4K
This repo provides a sample set of automated tests for http://commentssprintone.azurewebsites.net application.
There are two supported browsers:
firefox means Mozilla Firefoxchrome means Google ChromeThe tests are going to connect to a remote driver. It can be either a WebDriver run as a standalone process or Selenium Grid.
Also, please pay attention to configuration options and reporting.
First of all, you need to run desired WebDriver (chromedriver or geckodriver) as a standalone application (instructions for ChromeDriver). If you have a working Selenium Grid, you can use it instead.
Then, run the following command with the correct value for SELENIUM_URL and BROWSER (see configuration options for the details):
docker run -it \
--network=host \
--env SELENIUM_URL=http://host.docker.internal:4444 \
--env BROWSER=firefox \
--volume $(pwd)/allure-results:/jcat/allure-results \
extsoft/jcat:latest
:exclamation:As the browser driver is run on the localhost, we have to give proper URL for SELENIUM_URL option. Docker provides several networking features for each OS which allow binding of host machine's hostname into a container. As the result, if you bind a container to host's network with --net=host and want access host's resources, correct hostname is
host.docker.internal for Windows or OSXlocalhost for Linux:exclamation:If Selenium Grid is run on your local environment using docker, you have to add --network=<Selenium Grid network> to the command above.
To be able to use this type of run, you need to have Docker engine release
1.13.0+. A simple way to check:docker-compose -v
First of all, you need to download a YAML file:
curl -o docker-compose.yaml https://raw.githubusercontent.com/extsoft/jcat/master/docker-compose.yaml
Then, run tests:
docker-compose up --abort-on-container-exit --timeout 120
:exclamation: This command runs the Selenium Grid with firefox and chrome browsers and executes the tests in parallel. If you need one of browsers, add jcat-on-firefox or jcat-on-chrome to the end of the command.
After the tests execution, the Allure results directories are created: allure-results-chrome and allure-results-firefox.
If you need Selenium Grid for development purposes, run docker-compose up -d firefox60 chrome66. As the Grid's port is mapped to a host machine, you view Grid's console on http://localhost:4444/grid/console.
Use docker-compose down to destroy the environment.
mvn clean package (a JAR file is located under target directory and is named like comments-at-x.x.x-jar-with-dependencies.jar , where x.x.x is a version property from pom.xml).java -jar comments-at-x.x.x-jar-with-dependencies.jarFor instance,
java -Dbrowser=firefox -Dselenium-url=http://127.0.0.1:4444 \
-jar comments-at-0.1.0-jar-with-dependencies.jar
runs tests on Firefox browser using geckodriver started on 4444 port.
| Environment variable (Docker) | System property (Java) | Options | Default value (Docker / Java) | Description |
|---|---|---|---|---|
BROWSER | browser | eitherchrome or firefox | chrome / chrome | A browser for testing |
SELENIUM_URL | selenium-url | Any remote URL | http://selenium-hub:4444/wd/hub / http://localhost:9515 | An URL to remove driver or Selenium Grid |
The Allure files are stored to allure-results directory within the directory where you run the tests. Just run allure serve to see the Allure HTML report.



Content type
Image
Digest
Size
82.8 MB
Last updated
about 6 years ago
docker pull extsoft/jcat