Prepare Browser Options
To start a desktop browser session correctly, a browser options instance is necessary because it specifies the type of browser and sets up the session configuration.
Mobitru supports W3C standard Browser Options, which are described her.
In Selenium 3, those Options were known as capabilities, usually defined in a session by using Desired Capabilities classes.
You can find more information here.
Standard options
In order to start a general Browser Session, you need to prepare an instance of standard Browser options.
![]() | if you plan to use the standard browserVersion capability, please always specify the value in the following format: MAJOR.MINOR, for example browserVersion: 134.0 |
Below, you can find example of the preparing standard options for various browser types:
Chrome options:
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);
}
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)
it('chrome browser session init', async function () {
let driver = new Builder()
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
Firefox options:
public void startDriver() {
FirefoxOptions firefoxOptions = new FirefoxOptions();
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browserhub-us.mobitru.com/wd/hub"), firefoxOptions);
}
def start_driver():
options = webdriver.FirefoxOptions()
cloud_url = f"https://{BILLING_UNIT}:{ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub"
return webdriver.Remote(cloud_url, options=options)
it('firefox browser session init', async function () {
let driver = new Builder()
.forBrowser(Browser.FIREFOX)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
MS Edge options:
public void startDriver() {
EdgeOptions edgeOptions = new EdgeOptions();
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browserhub-us.mobitru.com/wd/hub"), edgeOptions);
}
def start_driver():
options = webdriver.EdgeOptions()
cloud_url = f"https://{BILLING_UNIT}:{ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub"
return webdriver.Remote(cloud_url, options=options)
it('edge browser session init', async function () {
let driver = new Builder()
.forBrowser(Browser.EDGE)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
Safari options:
public void startDriver() {
SafariOptions safariOptions = new SafariOptions();
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browserhub-us.mobitru.com/wd/hub"), edgeOptions);
}
def start_driver():
options = webdriver.SafariOptions()
cloud_url = f"https://{BILLING_UNIT}:{ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub"
return webdriver.Remote(cloud_url, options=options)
it('edge browser session init', async function () {
let driver = new Builder()
.forBrowser(Browser.SAFARI)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
Mobitru-specific options
Mobitru supports various additional features, such as video recording.
All of them are available for most browsers (except Safari) and can be activated using the Mobitru-specific options.
Those options should be defined additionally and specified in a Browser options instance using the “mobitru:options” key:
Video recording:
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()
});
Custom Locale or TimeZone:
public void startDriver() {
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> moonOptions = new HashMap<>();
moonOptions.put("env", Arrays.asList("TZ=Europe/Istanbul", "LC_ALL=de_AT.UTF-8"));
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 = {
'env': ['TZ=Europe/Istanbul','LC_ALL=de_AT.UTF-8']
}
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': {
'env': ['TZ=Europe/Istanbul','LC_ALL=de_AT.UTF-8']
}
}
let driver = new Builder()
.withCapabilities(mobitruOptions)
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
Custom Host entries:
public void startDriver() {
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> moonOptions = new HashMap<>();
moonOptions.put("hosts", Arrays.asList("example.com:1.1.1.1"));
chromeOptions.setCapability("mobitru:options", moonOptions);
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browser-testing-hub.epm-tstf.projects.epam.com/wd/hub"), chromeOptions);
}
def start_driver():
options = webdriver.ChromeOptions()
mobitru_options = {
'hosts': ['example.com:1.1.1.1']
}
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': {
'hosts': ['example.com:1.1.1.1']
}
}
let driver = new Builder()
.withCapabilities(mobitruOptions)
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});
Custom Browser profile:
public void startDriver() {
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> moonOptions = new HashMap<>();
moonOptions.put("context", "https://example-profile-storage.com/browser-profile.tar.gz");
chromeOptions.setCapability("mobitru:options", moonOptions);
RemoteWebDriver driver = new RemoteWebDriver(new URL("https://" + BILLING_UNIT+":" + ACCESS_TOKEN + "@browser-testing-hub.epm-tstf.projects.epam.com/wd/hub"), chromeOptions);
}
def start_driver():
options = webdriver.ChromeOptions()
mobitru_options = {
'context': 'https://example-profile-storage.com/browser-profile.tar.gz'
}
options.set_capability('mobitru:options', mobitru_options)
cloud_url = f"https://{BILLING_UNIT}:{ACCESS_TOKEN}@browser-testing-hub.epm-tstf.projects.epam.com/wd/hub"
return webdriver.Remote(cloud_url, options=options)
it('browser session init', async function () {
const mobitruOptions = {
'mobitru:options': {
'context': 'https://example-profile-storage.com/browser-profile.tar.gz'
}
}
let driver = new Builder()
.withCapabilities(mobitruOptions)
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});