Dead simple UI testing framework. (doozer.softtest.dev)
Doozer is released into Maven central repository and can be installed by adding this dependency into pom.xml file:
<dependency>
<groupId>dev.softtest</groupId>
<artifactId>doozer</artifactId>
<version>1.0.1</version>
</dependency>
With the latest updated in junit-jupiter-engine you need to also add the following plugin into the
plugins section to address the test discovery issue:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<systemPropertyVariables>
<environment>${test.folder}</environment>
</systemPropertyVariables>
</configuration>
</plugin>
Prerequisites:
- Java SDK
- Maven
Steps:
-
Create Maven project
- If you are creating a project from scratch then you need to update the Java version used by compiler (at least to version 8) in the pom.xml:
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target>
- Ensure all works well by running
mvn testcommand.
-
Add
doozerdependency into pom.xml -
Create
MyDoozerTestclass that extendsDoozerTestimport dev.softtest.doozer.DoozerTest; public class MyDoozerTest extends DoozerTest {}
This class is an entry point for various customizations, as long as you are not doing them it stays empty like at the example above.
Doozer test has a following structure:
firstTest (test directory)
├── firstTest.doozer (main test script named the same way as a directory + .doozer suffix)
└── goldens (directory for reference files, like images, a11y snapshots, logs, etc)
├── screenshot-1.png (exemplary golden file)
Steps:
-
Create a test directory, for example
firstTest -
Inside this directory, create
- a test script called:
firstTest.doozer - a
goldensdirectory for reference files
- a test script called:
-
Edit
firstTest.doozerand add first actionsurl args:"https://doozer.softtest.dev/test-pages/webform.html" assertPageTitle args:"doozerByExample - exemplary page to testing doozer actions"
-
Run the test with the following command:
mvn test -Ddoozer.test=<path_to_your_test>/firstTest/firstTest.doozer -Ddoozer.browser=chrome
or if you are running on Windows, add quotes around command parameters, like this:
mvn test "-Ddoozer.test=<path_to_your_test>/firstTest/firstTest.doozer" "-Ddoozer.browser=chrome"
NOTE: Running the test with
-Ddoozer.browser=chrometells the doozer to use Chrome as a browser for testing. By default the test would run on Chrome in headless mode so you'll not see much, with this parameter the browser is in headful mode. -
The results will be displayed in the console but also you can check all the logs at:
<your_working_directory>/target/doozer-tests, feel free to explore.
Positional parameters:
<action>[?]
<action>[?] "<selector>"
<action>[?] "<selector>" "<options>"
Named parameters:
<action>[?]
<action>[?] selector:"<selector>"
<action>[?] args:"<options>"
<action>[?] selector:"<selector>" args:"<options>"
Examples:
click "By.cssSelector('button')"
click "By.cssSelector('button')" "button=2,offsetX=10,offsetY=10"
click selector:"By.cssSelector('button')"
click selector:"By.cssSelector('button')" args:"button=2,offsetX=10,offsetY=10"
click selector:"Sl({button 'Accept *'})"
? - optional parameter indicating the execution should proceed despite action failure
-
Assertions
assertCurrentUrlassertInnerTextassertPageTitle
-
Interactions
alertclearclickcontextClickdeselectdoubleClickhoverhoverByOffsetkeyDownkeyUpselectsendKeystype
-
Navigation
navigateBacknavigateForwardnavigateTorefreshurl
-
Generics
addMaskexecuteScriptiframeimportsettakeScreenshotwaitwaitForElement
By.- By selectorsSl.- Semantic locators""- empty selector, for actions that don't use it
One of:
- single parameter
- a list of
key=valuepairs separated with,.
doozer.directory- defines a directory with doozer scriptsdoozer.test- defines a doozer script to rundoozer.browser- defines a browser to use during test, default:chrome-headlessdoozer.failOnPixelDiff- when set tofalseall thetakeScreenshotactions are treated as optional, default:true
The project is licensed with The Apache License, Version 2.0. (http://www.apache.org/licenses/LICENSE-2.0.txt).
Feel free to reach me out on github or at info [ at ] softtest.dev.
Enjoy!