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" % Test
See an example.
- System property
browser
must be set in order to execute tests. Argumentschrome
,edge
andfirefox
are available. - System property
environment
must be set in order to execute tests. Argumentslocal
,dev
,qa
andstaging
are typically available, but will depend on your project configuration. See an example. - System property
accessibility.assessment
is available to enable or disable the accessibility assessment. Argumentstrue
andfalse
are available, the default istrue
. - System property
security.assessment
is available to enable or disable the security assessment. Argumentstrue
andfalse
are available, the default isfalse
. - System property
browser.option.headless
is available to enable or disable headless browser mode. Argumentstrue
andfalse
are available, the default istrue
. - System property
browser.logging
is available to enable browser console logs when using Chrome. Argumentstrue
andfalse
are available, the default isfalse
.
Set system properties when executing tests as follows:
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.
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 ScreenshotOnFailure
See 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 test
Check all project files are formatted as expected as follows:
sbt scalafmtCheckAll scalafmtCheck
Format *.sbt
and project/*.scala
files as follows:
sbt scalafmtSbt
Format all project files as follows:
sbt scalafmtAll
This code is open source software licensed under the Apache 2.0 License.