Skip to content

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

3 watching

Forks

Latest commit

 

History

254 Commits

Folders and files

Repository files navigation

ui-test-runner

A helper library for UI testing at HMRC.

Usage

Declare dependency

Declare the library as a project dependency as follows:

"uk.gov.hmrc" %% "ui-test-runner" % "x.x.x" % Test

See an example.

Configuration

  • System property browser must be set in order to execute tests. Arguments chrome, edge and firefox are available.
  • System property environment must be set in order to execute tests. Arguments local, dev, qa and staging 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. Arguments true and false are available, the default is true.
  • System property security.assessment is available to enable or disable the security assessment. Arguments true and false are available, the default is false.
  • System property browser.option.headless is available to enable or disable headless browser mode. Arguments true and false are available, the default is true.
  • System property browser.logging is available to enable browser console logs when using Chrome. Arguments true and false are available, the default is false.
  • System property browser.bidi is available to enable the WebSocket connection for bidirectional communication with browser. Arguments true and false are available, the default is false.
  • System property browser.usePreviousVersion is available to enable the use of previous version of Chrome (v128). Arguments true and false are available, the default is false.

Browser Logging

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.*"

Browser

Start

Start a new browser session as follows:

startBrowser()

See an example.

Stop

Stop an existing browser session as follows:

quitBrowser()

See an example.

Driver instance

Starting a new browser session returns an instance of RemoteWebDriver as an object. Use as follows:

Driver.instance.<command>

See an example.

Download directory

The default directory for file downloads is target/browser-downloads.

Screenshot on failure

Enable screenshot on failure with ScreenshotOnFailure trait as follows:

with ScreenshotOnFailure

See an example.

Test environment configuration

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.

Development

Tests

Run tests as follows:

sbt clean test

Scalafmt

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

License

This code is open source software licensed under the Apache 2.0 License.

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages