Open topic with navigation

# SrfLab

## new SrfLab()

The SRF lab, where you can launch browsers or lock devices in SRF.

# Methods

## launchBrowser(browserCapabilities) → {Promise.<Web.BrowserTO>}

Launches a new browser tab, according to supplied Web.BrowserType or a browser capabilities property bag. Returning an instance of Web.Browser for the launched browser. The returned browser instance is valid until the tab is closed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`browserCapabilities` | string | object | the type of browser to launch: Possible values: Web.BrowserType, or a property bag defining the browser capabilities. ###### Properties
Name | Type | Description
--- | --- | ---
`type` | string | if a property bag is supplied, it must have the type key, Possible values: Web.BrowserType.

##### Returns:

a promise that is fulfilled with the browser instance.

Type
  Promise.<Web.BrowserTO>

## lockDevice(description, appsToInstallopt, deviceSourceopt) → {Promise.<Mobile.DeviceTO>}

Obtains a device from the SRF Mobile lab and locks it, so that only LeanFT can perform actions on it.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`description` | Mobile.Device | object |  | The description of the device or a device capabilities property bag.
`appsToInstall` | Array.<Mobile.Application> | <optional> | An Application array of applications to install on the device.
`deviceSource` | Mobile.DeviceSource | <optional> | The source location of the device. You can use the DeviceSource object or just pass one of its values as a string.

##### Returns:

a promise that is fulfilled with the locked device.

Type
  Promise.<Mobile.DeviceTO>

## lockDeviceById(deviceID) → {Promise.<Mobile.DeviceTO>}

Obtains a device from the SRF Mobile lab by deviceID and locks it, so that only LeanFT can perform actions on it.

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceID` | string | The device ID used by SRF Mobile lab.

##### Returns:

a promise that is fulfilled with the locked device.

Type
  Promise.<Mobile.DeviceTO>

## lockDeviceWithOptions(description, sessionOptions) → {Promise.<Mobile.DeviceTO>}

Supported in LeanFT versions 14.52 and later.
Obtains a device from the SRF Mobile lab and locks it, so that only the current LeanFT test can perform actions on it.

##### Parameters:

Name | Type | Description
--- | --- | ---
`description` | Mobile.Device| object | The description of the device or a device capabilities property bag.
`sessionOptions` | object | The session options to use. ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`appsToInstall` | Array.<Mobile.Application> | <optional> |  | An Application array of applications to install on the device.
`deviceSource` | Mobile.DeviceSource | <optional> |  | The source location of the device. You can use the DeviceSource object or just pass 'mobile_center', 'amazon_device_farm' or 'any' as a string.
`collectLogs` | bool | <optional> | true | Indicates whether logs should be collected in this session.
`collectVitals` | object | <optional> |  | Defines which device vitals should be collected in this session.
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`cpu` | bool | <optional> |  | Indicates whether to collect the device CPU usage.
`memory` | bool | <optional> |  | Indicates whether to collect the device memory usage.
`freeMemory` | bool | <optional> | true | Indicates whether to collect the device free memory.

##### Returns:

a promise that is fulfilled with the locked device.

Type
  Promise.<Mobile.DeviceTO>

## releaseEnvironment(envToRelease)

Release the allocated device environment.

##### Parameters:

Name | Type | Description
--- | --- | ---
`envToRelease` | Web.BrowserTO | Mobile.DeviceTO | the browser or device environment to release.