I'm using selenium webdriver on node.js (currently via webdriverio, but I don't mind switching to webdriverjs or wd).
I run some tests on different browsers and want to save results of each test along with information about the browser, for example:
How can I get the "desiredCapabilities" object from within the test?
Or how can I pass it to the test so it will be available?
EDIT
I found that browser.desiredCapabilities
returns the requested capabilities object, but now I realize I actually need the "actual capabilities" used (for example if I ask for IE8 on a machine that only has IE11 I get IE11 but the desiredCapabilities object shows version=8).
I'm looking for a way to get the actual used browser capabilities, as documented on selenium wiki:
If a session cannot support a capability that is requested in the desired capabilities, no error is thrown; a read-only capabilities object is returned that indicates the capabilities the session actually supports.
Using WebDriverJS (which you mentioned you could switch to), you can use getCapabilities
:
browser.getCapabilities().then(function (caps) {
console.log(caps);
});
The code above will just dump the capabilities but you should use the methods of the Capabilities
class to inspect the values. For instance:
browser.getCapabilities().then(function (caps) {
console.log(caps.get("browserName"), caps.get("version"));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With