Video recording
Mobitru supports the video recording of the entire Browser session and provides the specific API to download the recording in mp4 format.
This feature is available for all browsers except Safari and switched off by default.
Enable in tests
To start using the video recording in tests, it’s necessary to just add the enableVideo
option with true
as value.
Also, this option should be located inside the mobitru:options
map.
Below you can find an example for different programming languages:
public void startDriver() {
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> moonOptions = new HashMap<>();
moonOptions.put("enableVideo", true);
chromeOptions.setCapability("mobitru:options", moonOptions);
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browserhub-us.mobitru.com/wd/hub"), chromeOptions);
}
def start_driver():
options = webdriver.ChromeOptions()
mobitru_options = {
'enableVideo': True
}
options.set_capability('mobitru:options', mobitru_options)
cloud_url = f"https://{BILLING_UNIT}:{ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub"
return webdriver.Remote(cloud_url, options=options)
it('browser session init', async function () {
const mobitruOptions = {
'mobitru:options': {
'enableVideo': true
}
}
let driver = new Builder()
.withCapabilities(mobitruOptions)
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
Download the result .mp4 file
The .mp4 file with recording can be downloaded after end of a browser Session.
Important: please store the RemoteWebDriver session id before the end, because this value will be used in the download API call.
Below you can find an example of storing the session id:
public void startDriver() {
ChromeOptions chromeOptions = new ChromeOptions();
...
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browserhub-us.mobitru.com/wd/hub"), chromeOptions);
String sessionId = driver.getSessionId().toString();
}
def start_driver():
options = webdriver.ChromeOptions()
...
cloud_url = f"https://{BILLING_UNIT}:{ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub"
driver = webdriver.Remote(cloud_url, options=options)
session_id = driver.session_id
it('browser session init', async function () {
const mobitruOptions = {...}
let driver = new Builder()
.withCapabilities(mobitruOptions)
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
const sessionDetailsResponse = await driver.executeScript('browserstack_executor: {"action": "getSessionDetails"}');
const sessionDetails = JSON.parse(sessionDetailsResponse);
const sessionId = sessionDetails.hashed_id
});
Here is the example of CURL request to download a recording using stored session ID:
curl --location 'https://<BILLING_UNIT>:<ACCESS_KEY>@browserhub-us.mobitru.com/wd/hub/session/<RECORDING_ID>/recording'