-
Notifications
You must be signed in to change notification settings - Fork 51
WebDriver Automated Tests
You can see examples under functional-test module.
WebDriver is a great solution to write and maintain test code. It integrates well into maven build life cycle. You can find more information here.
Functional tests assume a zanata-{version}.war exists in server/zanata-war/target. So assuming you are at zanata server module top level folder:
$ls -d */
functional-test/ zanata-dist/ zanata-model/ zanata-war/
$mvn clean package -Pchromefirefox -DskipTests
... BUILD SUCCESS
$find zanata-war/target -type f -name "zanata*.war"
zanata-war/target/zanata-{version}.war
-Pchromefirefox builds GWT code to work with both. -Pfirefox will only build to work with firefox. -Pchrome will build for chrome only.
-DskipTests skip all unit tests for faster build time :)
$cd functional-test
$mvn verify -Dfunctional-test $arguments
You will then watch chrome/firefox pop up and the magic happen - assuming the environment is set up correctly.
All the command line arguments you can change when running functional-test can be found in functional-test/pom.xml
-Dwebdriver.display=$display will run the test browser in the targeted display. This is often favourable to having a window pop up that will interrupt your work and possibly cause failures in the test.
Xnest :1 -ac &
icewm --display=:1 &
mvn verify -Dfunctional-test -Dwebdriver.display=:1
The tests are assigned to a ${Category}TestSuite, i.e. BasicAcceptance, Detailed and Unstable TestSuite. Running:
mvn verify -Dfunctional-test -Dinclude.test.patterns="**/BasicAcceptanceTestSuite.java"
will execute the tests that make up the pull request validation suite.
Firefox may occasionally hang at random, for some users. Chrome seems to run better and faster. But unlike firefox, chrome requires a chromedriver in your system. You can download one (match your chrome version) from here.
$cd zanata-war
$mvn clean package -Pchrome -DskipTests
$cd ../functional-test
$mvn verify -Dfunctional-test -Dwebdriver.type=chrome -Dwebdriver.chrome.driver=/path/to/chromedriver -Dwebdriver.chrome.bin=/path/to/google-chrome
This assumes you have a zanata-{version}.war already build and you are currently under functional-test folder.
$mvn integration-test -Dfunctional-test -Dcargo.wait
$ ...
$[INFO] Press Ctrl-C to stop the container...
Now JBoss is running and Zanata is deployed. You can now run tests in IDE.
Under functional-test/src/(test|main)/java/org/zanata/
page/(Section)/(PageName)Page.java
The WebDriver mapped page objects. These represent a page in the Zanata application, with locators and "actions" one would take on said page. For example, clickSaveButton().
workflow/(WorkflowName)Workflow.java
These map to actual Zanata workflows. It encapsulates common user interactions, such as logging in, creating a project etc.
This is the factory class to create a singleton WebDriver instance to use. It will read in a properties file and based on the value it will create different driver (i.e. firefox, chrome, etc).
The Test Plan. Any test to be run by Zanata CI needs to be listed in this file. Try to keep this in the same folder order as listed alphabetically.
feature/testharness/(SuiteName)TestSuite.java
Test suite Categories, e.g. BasicAcceptance, for categorised test execution
feature/(Section)/*Test.java
The files run by junit runners using WebDriver to perform our automated tests, e.g. feature/account/RegisterTest.java.
This file is the properties file being used in WebDriverFactory. It will be filtered by maven.
Zanata config file used by tests. It will be filtered by maven.
Sample projects that are used to test zanata client server interaction. zanata.xml and pom.xml will be filtered by maven.
Everything else under this are test data documents, or files needed to set up a JBoss EAP6(AS7) instance for Zanata. See pom.xml under cargo maven plugin.