During project life-cycle we used Selenium/Robotframework to automate functional test cases. While these tools did a fantastic job on testing the functional correctness of the site that was been developed, we had challenges around UI alignment or UI not been correct (such as header, footer) etc. This tool is a simple utility to test UI correctness of any site works on basic image recognition using snapshot of pages (via Selenium).
The utility can work in a three modes
- Test Driver
- Standalone>
- API included in a framework
Test Driver
In this mode the program runs as a utility where it can drive a website using selenium. The commands are specified in a “teststep” file or a directory containing multiple “teststep” files which may be passed as a command line or in a configuration file. The run can be run in two modes.
STORE : This is to create a baseline based on the ‘teststeps’ file of pages that would need to be compared.
COMPARE: This is to run the same ‘teststeps’ file to compare against the baseline images by the STORE run.
Set the JAR file in the CLASSPATH
java org.sanjoy.uitest STORE config.file
Configuration
One mandatory command-line parameter is requires, which is the mode of the run. Which is either “STORE” or “COMPARE” (case in-sensitive), the operations of which are described above. The rest of the configuration parameters are specified in either as command line JVM argument using –Dkey=value or by specifying in the configuration file as a property file (key=value) format. The same configuration key can be specified as a JVM argument or configuration property key. For example
java Duiverify.verbose=true or in the configuration file specify ui.verbose=true
If a key is passed as a JVM argument and also in the configuration file, the value defined in the configuration file overrides the value passed as a JVM argument.
Configuration Key |
Valid Values |
Mandatory/Optional |
Remarks |
uiverify.testfile |
Path to a teststep file |
Mandatory (if uiverify.testdir not specified) |
Reads the commands to be executed on the selenium driver. Essentially a test driver. |
uiverify.testdir |
Path to a directory containing teststep files |
Mandatory (if uiverify.testfile not specified) |
Reads the directory for all files, which are treated as teststep files and are executed.
|
The following table enumerates the commands that can be specified in the “teststep” file to drive a browser. Each token is separated by a “,” character, the first token is always the keyword command. As an example to open “Chrome” browser the command in the “teststep” file would be
openBrowser, chrome
Keyword |
Arguments |
Remarks |
openBrowser |
|
The first argument is the name of the browser to launch, valid values are
|
Standalone
The standalone is triggered when the first argument is passed as “STANDALONE”. In this mode the utility runs always in COMPARE mode and doesn’t expect any teststep file as it doesn’t run any test. This mode is handy when with an existing test framework, snapshots are baseline and comparison images are taken and only differences and report generation is required. For existing assets, where a team doesn’t want to write new “teststeps” to be written again would be useful.
java org.sanjoy.uitest STORE config.file
Please read the “Configuration” section in “TestDriver” mode.
API
Read the source code and include as library
Results View
Clicking on the Show Difference
Have Fun!
Sanjoy Ghosh