Close

CAPABILITY GENERATOR

LambdaTestAutomation Testing ● Desired Capabilities in Selenium

Desired Capabilities in Selenium


LambdaTest Desired Selenium Capabilities Generator autogenerates the capabilities class needed to run your Selenium and Appium automation testing scripts on LambdaTest Selenium Grid. The Selenium capabilities generator will provide you with the entire code of capabilities class based on your mouse-interactions from the UI. Also, you will get the code for your selected configurations in all of the six programming languages i.e. Java, PHP, Ruby, JavaScript, C#, and Python.

This document will teach you how to leverage LambdaTest Capability Generator to easily for declaring desired capabilities in selenium for both desktop and mobile browsers.

In this document, we will talk about the following:

The values provided for any capability are both, space-insensitive and case-insensitive. This means that any value you provide as Mac OS X 10.13 or mac os x 10.13 would be correct.

Selenium Capabilities


Key
Values
Capability

browserName

  • Chrome
  • Firefox
  • Safari
  • MS Edge – Microsoft Edge
  • IE – Internet Explorer

This is a mandatory & case-sensitive capability which represents the name of the selected browser.

version

Example: 78.0

This capability is for the version of the browser mentioned above. This version you provide as a desired capability needs to be a valid one.

latest

The latest keyword will help you run your test cases over the most recent browser version available at LambdaTest.

latest-N

latest-5

This would allow you to execute your test over an older browser version. Here, N represents an integer. So if you wish to test your website over a browser version which was released 5 versions before the latest one. You can do so using the below capability:

platform

Supported Windows:

  • Windows 10
  • Windows 8.1
  • Windows 8
  • Windows 7

Supported MacOS:

  • Mojave
  • High Sierra
  • Sierra
  • El Capitan
  • Mavericks
  • Yosemite

If a platform for testing is not declared then LambdaTest will map your test to a relevant operating system for the selected browser.

So, if you wish to perform Selenium automation testing of your web application on Windows 10 then you need to mention the below line of code in your Desired Selenium Capabilities class.

Similarly for macOS, if you wish to perform Selenium automation testing of your web application on macOS Mojave then you need to mention the below line of code in your Desired Selenium Capabilities class.

resolution

  • 1024×768
  • 1280×800
  • 1280×1024
  • 1366×768
  • 1440×900
  • 1680×1050
  • 1600×1200
  • 1920×1200
  • 1920×1080
  • 2048×1536

This capability would help you to specify a particular screen resolution for your VM(Virtual Machine). By default, the resolution would be 1024×768.

name

Example: ToDo Sample Test

Represents the name of a test.

build

Example: 5.1

Represent the build number for your test.

Note: Build string should be less than 255 character

projectName

Example:My Test

Represent the name of a project.

tags

Example: {“Tag 1”, “Tag 2”, “Tag 3”}

Allows to group your automation tests.

For more details, visit our documentation.

buildTags

Example: {“Build Tags”}

Allows to group your tests builds.

For more details, visit our documentation.

lambda:loadExtension

Example: https://automation-prod-user-files.s3.amazonaws.com/extensions/orgId-XXXX/2.1.0_0.zip

Allows to test .zip extension files uploaded on LambdaTest storage.

To upload extension on LambdaTest storage, refer to our documentation.

lambda:userFiles

Example:804402.png

Allows to test the uploaded files on LambdaTest.

For more details about uploading files, visit our documentation.

Desired Capabilities in Selenium 4


We have introduced a new tab for desired Capabilities in Selenium 4 in our Desired Capabilities Generator. With respect to Selenium 4, there a few changes to observe while declaring the Desired Selenium Capabilities class.

Selenium 4 capabilities

Here is a table to represent the capabilities that have been updated or newly introduced for Selenium 4.

Key
Values
Capability

user

Example:
harshitp

Can be found under your LambdaTest profile. If you are already logged into LambdaTest then the Desired Selenium Capabilities Generator will automatically fetch your LambdaTest username under the desired Selenium capabilities class.

accessKey

Example: 123ABC

Can be found under your LambdaTest profile. If you are already logged into LambdaTest then the Desired Selenium Capabilities Generator will automatically fetch your LambdaTest Access Key under the desired Selenium capabilities class.

browserVersion

Ex: 79.0

This capability is used to declare the specific browser version on which you want your test automation scripts to be executed using our Selenium Automation Grid. Make sure to provide a valid browser version in your desired Selenium capabilities class.

latest

The latest keyword will help you run your test cases over the most recent browser version available at LambdaTest.

latest-N

latest-5

This would allow you to execute your test over the older browser versions. Here, N represents an integer. So if you wish to test your website over the 5 most recently released browser versions. You can do so using the below capability:

platformName

Supported Windows:

  • Windows 10
  • Windows 8.1
  • Windows 8
  • Windows 7

Supported MacOS:

  • Mojave
  • High Sierra
  • Sierra
  • El Capitan
  • Mavericks
  • Yosemite

This capability is used to specify the platform on which you wish to run your Selenium automation testing. If a platform for testing is not declared then LambdaTest will map your test to a relevant operating system for the selected browser.

So, if you wish to perform Selenium automation testing of your web application on Windows 10 then you need to mention the below line of code in your Desired Selenium Capabilities class.

Similarly for macOS, if you wish to perform Selenium automation testing of your web application on macOS Mojave then you need to mention the below line of code in your Desired Capabilities class.

Appium Capabilities


We have come up with a new tab for Appium in our Desired Capabilities Generator. Here are the unique capabilities that you may have to keep in mind while executing appium tests using LambdaTest Selenium Grid.

Key
Values
Capability

deviceName

Example:

  • Galaxy S10
  • iPhone XS

This capability allows you to specify the particular device on which you wish to run your appium automation testing.

Similarly for iPhone XS, the capability would be as follow.

platformVersion

Example:

  • Android 9.0
  • iOS 12.1

This capability allows you to specify the particular Android OS version or iOS version, for which you wish to run your appium automation testing.

In case you wish to run your tests on Android version 9.0, then you will get the below capability for Java from our capability generator.

Similarly if you wish to run for iOS version 12.1, you may get the below capability from our Desired capabilities generator.

To check the entire list of devices available, along with operating systems for different desktop and mobile browsers, visit our list of browsers.

Selenium Automation Testing From Different GeoLocations


We have come up with a new Capability drop down that would allow you to run your test from different geographies across the world.

Key
Values
Capability

geoLocation

Example: US

This capability helps you to perform Selenium automation testing from different countries.

You can perform Selenium automation testing from the below listed countries.

  • Argentina
  • Australia
  • Austria
  • Belgium
  • Brazil
  • Bulgaria
  • Canada
  • Chile
  • China
  • Colombia
  • Croatia
  • Czech Republic
  • Denmark
  • Egypt
  • Finland
  • France
  • Germany
  • Greece
  • Hong Kong
  • Hungary
  • Iceland
  • India
  • Indonesia
  • Ireland
  • Israel
  • Italy
  • Japan
  • Jordan
  • Malaysia
  • Mexico
  • Morocco
  • Netherlands
  • New Zealand
  • Nigeria
  • Norway
  • Philippines
  • Poland
  • Portugal
  • Russia
  • Singapore
  • South Africa
  • South Korea
  • Spain
  • Sweden
  • Switzerland
  • Taiwan
  • Thailand
  • Turkey
  • Ukraine
  • United Kingdom
  • United States
  • Venezuela
  • Vietnam

Important Note: You cannot perform Geolocation testing with locally hosted web applications using LambdaTest Tunnel in a single test case. If you wish to perform both then you can leverage parallel testing to run two tests simultaneously, one for Geolocation and the other for LambdaTest Tunnel.

LambdaTest Advanced Selenium Capabilities


In this table, LambdaTest advanced capabilities key,values and capabilities are listed.

Key
Values
Capability

video

true, false

By default, the video is set as true. This capability helps in video recording of the complete screen while the test gets executed. You can record maximum up to 10 minutes. In case you need to turn off the video recording, you can do so by turning off the button on our Desired Capabilities Generator.

If you turn the video flag off, then for Java, it may provide the below piece of code in the capabilities class.

visual

true, false

Command by command screenshots will be recorded at each test step. By default the flag is set as off.
Note: test execution time will increase if it’s set as ‘true’.

network

true, false

Captures a recording for network packets while the test gets executed. By default, the network flag is set as false.

Note: test execution time will increase if it’s set as ‘true’.

console

true, false

Javascript logs will be recorded for the test. By default, it is set as false.

Note: test execution time will increase if it’s set as ‘true’.

tunnel

true, false

To test your locally hosted web application with LambdaTest Tunnel which establishes an SSH(Secure Shell) connection between your system and our cloud servers. By default, the tunnel flag, will be set as false.

Find more about LambdaTest Tunnel from our documentation to test on locally hosted web applications.

tunnelName

Your desire tunnel name

To provide the tunnel identifier in your test suite capability when user wants to execute the test through a particular tunnel

timezone

Example: UTC-05:00

Represents the custom timezone you select for executing a test.

View Lighthouse Performance Metrics


LambdaTest now integrates Lighthouse to view the performance metrics (Lighthouse Audits) on its online cloud based Selenium Grid. You can now view the scores of:

  • Performance,
  • Accessibility,
  • Best Practices,
  • SEO, and
  • Progressive Web App

metrics with the help of LambdaTest.

You can view the Lighthouse Performance metrics by enabling capability via code, using the below syntax:

Please refer this document for complete details.

Network Throttling


In order to validate your website on different network profiles (LTE/3G/2G), you can simulate these network conditions using our capabilities.

Key
Values
Capability
networkThrottling Regular 4G, Regular 3G, Regular 2G, Good 3G, Good 2G, Offline, Reset, GPRS, DSL Based on the user provided input, this capability helps to start test suite with default network. For example, if user selects the value Regular 4G then the capabilities will look like this:

For more info, visit our documentation Network Throttling.

Headless Browser


You can now perform Headless browser testing easily, by adding their capability in your desired capabilities.

You can either do that, by selecting the option Headless, under the browser specific capabilities in the Desired Capabilities Generator, as shown in the image below:

Or you can just enable the Headless capability via code, using the below syntax:

Please refer this document for complete details.

Default Selenium Capabilities


Key
Values
Capability
javascriptEnabled true, false Based on the user provided input, this capability helps to enable the support for JavaScript execution.
databaseEnabled true, false Decides if a session could communicate with the database.
locationContextEnabled true, false Decides if a session can use the features with respect to different geographic locations.
applicationCacheEnabled true, false Decides if a session is able to utilize the application cache.
browserConnectionEnabled true, false Determines the browser connectivity with respect to the query involved in the session. Also checks whether the session can be disabled if required by the end user.
webStorageEnabled true, false Decides if a session is able to connect with storage objects.
acceptSslCerts true, false Decides if a session by default should accept all SSL certificates.
unexpectedAlertBehaviour accept, dismiss, ignore Determines the action of a browser for handling alerts, prior to pointing the UnhandledAlertException.
elementScrollBehavior integer Determines the scrolling behavior according to the user provided input. The user can decide if the elements should be aligned to top(0) or bottom(1) with respect to the elements scroll-ability inside the viewport. By default the value is set to 1, aligning the scroll behavior to top. This is compatible in IE and Firefox (since 2.36)

Hide/Mask Sensitive Information Through Selenium Capabilities


With the help of maskCommands capability, you can now hide sensitive and important data, sent to or retrieve from the remote browsers at LambdaTest. When used, this will hide all the keystrokes and other required values, and replace them with ‘*’ in test session logs (both text and raw).

Syntax (Java):

List of comma separated values that can be hidden:

Value
Decription
setValues Hide/Redact all the text sent via sendKeys command.
setCookies Hide/Redact all the cookies set by the addCookie command.
getCookies Hide/Redact all the cookie values obtained using the getCookies and getCookieNamed command.

For example:

Language
Example
Java capabilities.setCapability(“lambdaMaskCommands”, {“setValues”, “setCookies, getCookies”});
Node.js capabilities[‘lambdaMaskCommands’] = [“setValues”, “setCookies”, “getCookies”]
C# capabilities.SetCapability(“lambdaMaskCommands”, {“setValues”, “setCookies”, “getCookies”});
PHP $capabilities[“lambdaMaskCommands”] = array(“setValues”, “setCookies”, “getCookies”)
Python capabilities[“lambdaMaskCommands”] = [“setValues”, “setCookies”, “getCookies”]
Ruby capabilities[“lambdaMaskCommands”] = [“setValues”, “setCookies”, “getCookies”]