An example project which shows the abilities of automated testing using JUnit4, Selenium WebDriver and Allure
This project intentionally created as simple as possible to effectively explain the abilities of the tools.
The example is set to use Internet Explorer driver, therefore some preinstallation steps required:
- Download InternetExplorerDriver
- Configure
System.setProperty("webdriver.ie.driver")
in source codeYandexMarketTest.java
- specify the full path to downloaded InternetExplorerDriver.exe - You will need Maven installed on your computer (to check if you have one, run "mvn -version" in command line)
- Set
JAVA_HOME
system variable to your JDK (Java Developmen Kit) library. If you don't have the JDK yet, it's time to download one.
NOTE – a path to JDK (not JRE) is requires, e.g. see example below:
Before running any tests, in order to get the InternetExplorerDriver working, it needs to set same Security level in all zones. To do that follow the steps below:
- Open IE
- Go to Tools -> Internet Options -> Security
- Set all zones (Internet, Local intranet, Trusted sites, Restricted sites) to the same protected mode, enabled or disabled should not matter. I personally enabled protected mode for all zones and automated tests works just fine to me.
Finally, set Zoom level to 100% by right clicking on the gear located at the top right corner and enabling the status-bar. Default zoom level is now displayed at the lower right.
This setup required just once.
More info about these settings on the links:
.sendKeys()
method runs too slow on InternetExplorerDriver x64 bit version. The solution is simple - switch to 32bit version of driver fix the issue. And don't forget to update InternetExplorerDriver path in System.setProperty("webdriver.ie.driver")
More info about this issue on: WebDriver and IE10 very slow input
Import into your favourite IDE (e.g., Eclipse or IDEA) and run the project. It configured to trigger the JUnit tests and show you the results.
To just run the JUnit test, open command line, change dir to project folder where you have cloned this repository and where pom.xml is, then run following command:
mvn clean test
-> Maven will clean up old precompiled code and artefacts, then run tests in browser
Once the tests have passed (or failed :), you can generate Allure report using one of the following command:
mvn allure:serve
-> Report will be generated into temp folder. Web server with results will start and open in browser. You can terminate the plugin with a ctrl-c in the terminal window where it is running.
mvn allure:report
-> Report will be generated tо directory: target/site/allure-report/index.html
This plugin generates Allure report by existing XML files during the Maven build process. More details on setup (for new projects only) https://docs.qameta.io/allure/2.0/#_maven_4
To conclude, all-in-one command to prepare maven project, then run tests, then build and show Allure report is:
mvn clean test allure:serve
This should work in most cases.
As a suggestion for dynamic-development projects I would recommend jetty-maven-plugin.
I do not want to include this one in the example to keep it simple and include only necessary things for the work of a bundle Junit+Webdriver+Allure. But you can try.