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>0.2.10</version>
</dependency>
Current version - 0.2.10 - is not final but it is functional enough to try it out.
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 test
command.
-
Add
doozer
dependency into pom.xml -
Create
MyDoozerTest
class that extendsDoozerTest
import 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
goldens
directory for reference files
- a test script called:
-
Edit
firstTest.doozer
and 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=chrome
tells 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
assertCurrentUrl
assertInnerText
assertPageTitle
-
Interactions
alert
clear
click
contextClick
deselect
doubleClick
hover
hoverByOffset
keyDown
keyUp
select
sendKeys
type
-
Navigation
navigateBack
navigateForward
navigateTo
refresh
url
-
Generics
addMask
executeScript
iframe
import
set
takeScreenshot
wait
waitForElement
By.
- By selectorsSl.
- Semantic locators""
- empty selector, for actions that don't use it
One of:
- single parameter
- a list of
key=value
pairs 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-headless
doozer.failOnPixelDiff
- when set tofalse
all thetakeScreenshot
actions 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!