Serenity BDD LambdaTest Integration
LambdaTest is a cloud platform for test execution and test orchestration. With LambdaTest, Serenity users can extend their automation test coverage of their web and mobile apps on 3000+ real devices, browsers, and operating systems.
The serenity-lambdatest
plugin provides seamless integration with the LambdaTest online test automation platform.
#
Adding the LambdaTest pluginTo add the integrated support for LambdaTest to your project, you will need to add the serenity-lambdatest
dependency to your project dependencies. For Maven, you would add the following:
<dependency> <groupId>net.serenity-bdd</groupId> <artifactId>serenity-lambdatest</artifactId> <version>${serenity.version}</version> </dependency>
And for Gradle:
testImplementation "net.serenity-bdd:serenity-lambdatest:${serenityVersion}"
#
Specifying your LambdaTest credentials and grid URLNext, you will need a LambdaTest account (If you don't already have one you can set up a free lifetime account to experiment).
You can add your LambdaTest credentials in two ways. The simplest is to define the following system properties:
LT_USERNAME
- LambdaTest user nameLT_ACCESS_KEY
- LambdaTest access key
Alternatively, you can define your username and accesskey using the lt.user
and lt.key
properties respectively in your serenity.conf
file:
lt.user=myuserlt.key=XXXXXXXX
By default the standard LambdaTest grid URL ("hub.lambdatest.com") will be used to connect to the LambdaTest servers, but you can override this by setting the lt.grid
property:
lt.grid = "mycustomhub.lambdatest.com"
#
Configuring the LambdaTest driverSerenity interacts with LambdaTest via the RemoteDriver
driver. You can specify the remote URL explicitly, or let the serenity-lambdatest
library do it for you. For example, to configure the URL explicitly you could use a serenity.conf
configuration like this:
webdriver { driver = remote remote.url = "https://"${LT_USERNAME}":"${LT_ACCESS_KEY}"@hub.lambdatest.com/wd/hub"}
If the webdriver.remote.url
property is not defined, Serenity will use these values to build one for you if the LambdaTest plugin is active (see below).
#
Activating the LambdaTest pluginThe Serenity LambdaTest plugin will be invoked if Serenity can find a "LT:Options"
section in your serenity.conf
file, or if you specify a remote.webdriver.url
that points to a LambdaTest server. If you have no LambdaTest-specific capabilities, simply set the lambdatest.active
property to true like this:
lambdatest { active = true}
#
Defining LambdaTest CapabilitiesYou can specify the operating system and browser you want to run your tests on by customising the Selenium Capabilities in your serenity.conf
file. You do this in the "LT:Options"
section of the serenity.conf
file, e.g.
webdriver { driver = "remote" capabilities { browserName = "chrome" version = "104.0" platform = "Windows 10" # # Any LambdaTest-specific options go in the 'LT:Options' section # "LT:Options" { resolution", "1280x800" network = true // To enable network logs visual = true // To enable step by step screenshot video = true // To enable video recording console = true // To capture console logs } } }
Note that the w3c
option will be set to true
by default, as this is the default protocol for the Selenium version integrated with Serenity.
The LambdaTest test name will be assigned automatically. You can also set the build name by assigning the lambdatest.build
property.
For example the following example shows how to create a build name from the Jenkins job name and build number environment variables:
lambdatest { build = "${JOB_NAME} - build ${BUILD_NUMBER}"}
These properties will be placed in the LT:Options
capability.
tip
LambdaTest provides a convenient Capabilities Generator that gives an idea of what options are available.