Nodejs selenium webdriver - Get browser capabilities inside a test?

I'm using selenium webdriver on node.js (currently via webdriverio, but I don't mind moving to webdriverjs or wd).

I am running multiple tests in different browsers and want to save the results of each test along with the browser information, for example:

  • Test 1 - chrome - 199 assertions, 0 failures, 0 skipped
  • Test 1 - IE9 - 199 assertions, 0 errors, 0 missed
  • etc..

How can I get the "readyCapabilities" object from a test?

Or how to submit it to the test so that it is available?

EDIT

I found that I was browser.desiredCapabilities

returning an object with the requested capabilities, but now I understand that I really need "actual capabilities" (for example, if I ask IE8 on a machine that has IE11, I get IE11, but the desired object object shows version = 8) ...

I'm looking for a way to get the actual browser capabilities used, as described in the selenium wiki :

If the session does not support the feature requested in the desired capabilities, no error occurs; a read-only capability object is returned that indicates the capabilities the session actually supports.

+3


source to share


1 answer


Using WebDriverJS (which you talked about you can switch to) you can use getCapabilities

:

browser.getCapabilities().then(function (caps) {
    console.log(caps);
});

      



The above code just dumps the capabilities, but you must use Capabilities

class
methods to validate the values. For example:

browser.getCapabilities().then(function (caps) {
    console.log(caps.get("browserName"), caps.get("version"));
});

      

+3


source







All Articles