The Browser Object
If you use the WDIO test runner, you can access the WebDriver instance through the global browser
or driver
object.
The session is initialized by the test runner. 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
Get Config Options
If using the WDIO testrunner you can always define custom options within your WDIO config:
And access it in your tests:
Mobile Flags
If you need to modify your test based on whether or not your session runs on a mobile device, you can access the mobile flags to check.
For example, given this config:
You can access these flags in your test like so:
This can be useful if, for example, you want to define selectors in your page objects based on the device type, like this:
You can also use these flags to run only certain tests for certain device types: