Run tests for custom environment
Mobitru supports the test execution for websites, hosted on some private network.
Below is detailed information for preparing such execution and configuring your tests properly.
This feature is available for all browsers except Safari.
Start a local tunneling session
The test execution is based on tunneling requests from the Mobitru to a machine located in the private network.
According to this, it’s necessary to start a local tunneling session using the mobitru-browser-tunneling tool.
We can provide the tool by request and it looks like a simple binary file, which should be executed from the CLI.
Below you can find an example of steps for starting a tunneling session:
- Open the folder with the mobitru-browser-tunneling tool in a CMD/Terminal application.
- Paste the command to the CMD/Terminal:
Local tunneling: name_of_the_tool --api-key <ACCESS_KEY> --host browserhub-us.mobitru.com --local-identifier <LOCAL_IDENTIFIER_KEYWORD>
Example for Mac: ./mobitru-browser-tunneling-darwin-amd64 --api-key mobitru_ak_.... --host browserhub-us.mobitru.com --local-identifier cross-browsing
You will see the following message, if a session will be successfully started:
Configure tests
After starting a tunneling session, it’s necessary to add the local-identifier value to the tests capabilities.
It can be done by adding the following option localIdentifier
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("localIdentifier", "cross-browsing");
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 = {
'localIdentifier': 'cross-browsing'
}
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': {
'localIdentifier': 'cross-browsing'
}
}
let driver = new Builder()
.withCapabilities(mobitruOptions)
.forBrowser(Browser.CHROME)
.usingServer(`https://${BILLING_UNIT}:${ACCESS_TOKEN}@browserhub-us.mobitru.com/wd/hub`)
.build()
});