Code illustrating testng, screenshots and REST comparisons see also https://github.com/donhenton/selenium-sandbox
To run the service and screenshot test:
mvn clean test -Pdev -DtestNgFile=sample
OR
mvn clean test -Pdev -DtestNgFile=sample -Dremote.server=docker
if the local docker instance is configured, its url will be in the env.properties file of the environment (dev,prod)
Once the tests are run, the report will be in target/surefire-reports/html/index.html The reporting code responsible is at https://github.com/donhenton/reportng, and is a forked modification. The mod points to two pages that have been added to the output.
- target/classes/public_html/index.html (screenshot comparisons)
- target/classes/service_public_html/index.html (json comparisons)
- testng reporting suite -- target/surefire-reports/html/index.html
This webpage presents a stored gold file image, compares its to the image freshly visited, and highlights the differences. Specialized code is used to generate the image, see MainAppScreenShot.java and ScreenshotComparisonTest.java
This webpage illustrates comparing the output of a REST service to a gold file of the same service. Comparisons use Levenshtein algorithm for the comparison. See RestaurantTests.java
The current code base needs requires firefox. So docker image that works is
https://github.com/SeleniumHQ/docker-selenium
docker run -d -p 4470:4444 --shm-size 2g selenium/standalone-firefox:3.141.59-radium
The display page will be at http://localhost:4470/wd/hub where dockerlocal refers to the ip of your docker-toolbox vm (docker-machine ip to find it) if you use the dstart.sh script to launch the docker container
At this moment this code uses Selenium < 3, and would need an update if the selenium driver were changed.
This project depends on two other projects in my repository, which you will have to install locally:
An XML Utils library is also required:
https://github.com/donhenton/code-attic/tree/master/utils/XmlUtils