Custom host aliases
Mobitru supports browser session’s custom host aliases, which allows using custom hostname:IP pairs in tests.
This feature is available for all browsers except Safari.
Enable in tests
To start using the custom host aliases, it’s necessary to add the hosts
option with an array as a value.
The array should contain item(s) with hostname:IP pair like example.com:1.1.1.1
:
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("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 + "@browserhub-us.mobitru.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()
});