A helper library for UI testing at HMRC.
Declare the library as a project dependency as follows:
"uk.gov.hmrc" %% "ui-test-runner" % "x.x.x" % TestSee an example.
- System property
browsermust be set in order to execute tests. Argumentschrome,edgeandfirefoxare available. - System property
environmentmust be set in order to execute tests. Argumentslocal,dev,qaandstagingare typically available, but will depend on your project configuration. See an example. - System property
accessibility.assessmentis available to enable or disable the accessibility assessment. Argumentstrueandfalseare available, the default istrue. - System property
security.assessmentis available to enable or disable the security assessment. Argumentstrueandfalseare available, the default isfalse. - System property
browser.option.headlessis available to enable or disable headless browser mode. Argumentstrueandfalseare available, the default istrue. - System property
browser.loggingis available to enable browser console logs when using Chrome. Argumentstrueandfalseare available, the default isfalse. - System property
browser.bidiis available to enable the WebSocket connection for bidirectional communication with browser. Argumentstrueandfalseare available, the default isfalse. - System property
browser.usePreviousVersionis available to enable the use of previous version of Chrome (v128). Argumentstrueandfalseare available, the default isfalse.
Browser logging is disabled by default for all log types. You can selectively enable or configure specific log types using system properties.
Enable/Disable Properties:
browser.logging- Browser console logs (default:false)driver.logging- WebDriver command logs (default:false)performance.logging- Network/performance logs (default:false)
Log Level Properties:
browser.logging.level- Browser log level (default:ALL)driver.logging.level- Driver log level (default:ALL)performance.logging.level- Performance log level (default:ALL)
Valid log levels: ALL, INFO, WARNING, SEVERE
Browser Support:
Chrome and Microsoft Edge fully support Browser, Driver and Performance logs
Firefox does not support Browser, Driver and Performance logs. It only supports Server log which is not useful for test debugging.
Log Output:
Logs are saved to files in target/test-reports/browser-logs/ with minimal console output showing only the file path.
Set system properties when executing tests as follows:
Default (all logging disabled):
sbt -Dbrowser="<browser>" -Denvironment="<environment>" -Daccessibility.assessment="<accessibility.asessment>" -Dsecurity.assessment="<security.asessment>" -Dbrowser.option.headless=<browser.option.headless> "testOnly uk.gov.hmrc.ui.specs.*"See an example.
With selective logging (only browser console):
sbt -Dbrowser="<browser>" -Denvironment="<environment>" -Dbrowser.logging=true "testOnly uk.gov.hmrc.ui.specs.*"With custom log levels:
sbt -Dbrowser="<browser>" -Denvironment="<environment>" -Dbrowser.logging=true -Dbrowser.logging.level=INFO "testOnly uk.gov.hmrc.ui.specs.*"Start a new browser session as follows:
startBrowser()See an example.
Stop an existing browser session as follows:
quitBrowser()See an example.
Starting a new browser session returns an instance of RemoteWebDriver as an object. Use as follows:
Driver.instance.<command>See an example.
The default directory for file downloads is target/browser-downloads.
Enable screenshot on failure with ScreenshotOnFailure trait as follows:
with ScreenshotOnFailureSee an example.
Test environment configuration is available. A configuration file is required to use it. See an example.
Create a url from a configuration file as follows:
val url: String = TestEnvironment.url("service") + "/path"See an example.
Run tests as follows:
sbt clean testCheck all project files are formatted as expected as follows:
sbt scalafmtCheckAll scalafmtCheckFormat *.sbt and project/*.scala files as follows:
sbt scalafmtSbtFormat all project files as follows:
sbt scalafmtAllThis code is open source software licensed under the Apache 2.0 License.