The Browser Object
If you use the wdio test runner you can access the webdriver instance through the global browser
object. The session is initialized by the test runner so you don’t need to call init
command. The same goes for ending the session. This is also done by the test runner process.
Besides all commands from the api the browser object provides some more information you might be interested in during your test run:
Get desired capabilities
1 2 3 4 5 6 7 8 9 10 11 12
| console.log(browser.desiredCapabilities);
|
Get wdio config options
1 2 3 4 5 6
| exports.config = { foobar: true, }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| console.log(browser.options);
|
Check if capability is a mobile device
1 2 3 4 5 6 7 8 9 10 11 12
| var client = require('webdriverio').remote({ desiredCapabilities: { platformName: 'iOS', app: 'net.company.SafariLauncher', udid: '123123123123abc', deviceName: 'iPhone', } });
console.log(client.isMobile); console.log(client.isIOS); console.log(client.isAndroid);
|
Log results
1
| browser.logger.info('some random logging');
|
For more information about the logger class check out Logger.js on GitHub.