BrowserStack Plugin

The plugin provides integration with continuous testing cloud BrowserStack.

Installation

  1. Copy the below line to dependencies section of the project build.gradle file

    Example 1. build.gradle
    implementation(group: 'org.vividus', name: 'vividus-plugin-browserstack', version: '0.5.10')
  2. If the project was imported to the IDE before adding new plugin, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.

Profiles

The plugin defines profiles with a set of the preconfigured properties.

browserstack/web

Use in conjunction with web application profiles.

browserstack/web/phone

Use in conjunction with web application phone profiles. Required properties:

  • selenium.grid.device-name

browserstack/mobile_app

Use in conjunction with native mobile application profiles.

Required properties:

  • selenium.grid.device-name

BrowserStack profiles can be enabled by adding the corresponding entry to configuration.profiles property.

Example 2. Configure Chrome on BrowserStack
configuration.profiles=browserstack/web,web/desktop/chrome
BrowserStack profile must be first.

Explore BrowserStack Capabilities for more fine-grained configuration.

Links to BrowserStack test runs can be found in Allure report

Properties

The properties marked with bold are mandatory.
Property Name Acceptable values Default Description

selenium.grid.host

hostname

hub-cloud.browserstack.com

BrowserStack remote end host to be used to create a new session

selenium.grid.username

username

<empty>

BrowserStack username

selenium.grid.password

password

<empty>

BrowserStack access key

browserstack.browserstack-local.enabled

true false

false

Enables BrowserStack Local

  • BrowserStack specific properties must be prepended with prefix

    selenium.grid.capabilities.bstack\:options.

    Meaning, given a property projectName with a value My Project, the resulting property will be

    selenium.grid.capabilities.bstack\:options.projectName=My Project
  • Appium specific properties in BrowserStack must be prepended with prefix

    selenium.grid.capabilities.appium\:options.

    Meaning, given a property clearSystemFiles with a value true, the resulting property will be

    selenium.grid.capabilities.appium\:options.clearSystemFiles=true

Enable network capturing

The following options are available to enable network logs capturing on BrowserStack side:

  • Add selenium.grid.capabilities.bstack:options.networkLogs=true property into tests configuration, this will enable network logs capturing for all stories in suite.

  • Add @capability.bstack:options.networkLogs true meta for a story being run

  • Pass the capability with name bstack:options.networkLogs and value true as parameter to the step starting native mobile application. .Enable network logs in the step starting application

Given I start mobile application with capabilities:
|name                      |value|
|bstack:options.networkLogs|true |

Steps

Save network logs into variable

Saves network traffic captured during application run into variable. The network traffic data is in HAR format. The application session must be closed before network logs can be saved.

When I save BrowserStack network logs to $scopes variable `$variableName`
  1. $scopes - The comma-separated set of the variables scopes.

  2. $variableName - name of variable to save network logs

Example 3. Save network logs into variable
When I close mobile application
When I save BrowserStack network logs to SCENARIO variable `networkLogs`
Then number of JSON elements from `${networkLogs}` by JSON path `$..*[?(@.url == 'https://graph.example.com/v8.0')]` is equal to 1

Save network logs into context

Saves network traffic captured during application run into JSON context. The network traffic data is in HAR format. The application session must be closed before network logs can be saved.

When I save BrowserStack network logs to JSON context

To interact with the saved network logs see JSON steps that work with the JSON context

Example 4. Save network logs into variable
When I close mobile application
When I save BrowserStack network logs to JSON context
Then number of JSON elements from `${networkLogs}` by JSON path `$..*[?(@.url == 'https://graph.example.com/v8.0')]` is equal to 1