Protractor: browser.getCapabilities() no longer returning capabilities.caps_ (Protractor 3.2)

Created on 18 Mar 2016  路  8Comments  路  Source: angular/protractor

  • Protractor Version: 3.2

browser.getCapabilities() used to return an object with caps_ which was readable, and could be used to examine the browserName and version.

Which I can still output the returned capabilities to console, I can't seem to access any of the properties on it anymore, and so our tests won't run in 3.2.

How can we access the browserName and version in 3.2?

WebDriver issufeature

Most helpful comment

Thanks Julie - appreciated :)

For anyone else looking here, you'll need to use (e.g.) capabilites.get('browserName')

All 8 comments

This is due to changes in the selenium-webdriver module in version 2.52.

See their release notes here: https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/CHANGES.md#v2520

Capabilities now extends native map, so you should be able to use .has(<key>) to get at the info you were using before.

As a future FYI - properties with an underscore are generally considered private and subject to change without notice.

I'll update the CHANGELOG to include a link to to the selenium-webdriver changelog.

Thanks Julie - appreciated :)

For anyone else looking here, you'll need to use (e.g.) capabilites.get('browserName')

Sorry to write a new comment in this closed issue, but I'm trying to figure out what is the correct way to get the capabilities now? I mean if you use the former:

browser.getCapabilities().then((c) => {
  console.log(c)
})

it outputs (e.g.):

Capabilities {
  'acceptSslCerts' => true,
  'applicationCacheEnabled' => false,
  'browserConnectionEnabled' => false,
  'browserName' => 'chrome',
  'chrome' => {},
  'cssSelectorsEnabled' => true,
  'databaseEnabled' => false,
  'handlesAlerts' => true,
  'hasTouchScreen' => false,
  'javascriptEnabled' => true,
  'locationContextEnabled' => true,
  'mobileEmulationEnabled' => false,
  'nativeEvents' => true,
  'platform' => 'ANDROID',
  'rotatable' => false,
  'takesHeapSnapshot' => true,
  'takesScreenshot' => true,
  'version' => '37.0.0.0',
  'webStorageEnabled' => true }

Then, how to get access to these properties (Capabilities is not an object)?

@yamafaktory

Use (e.g.):

c.get('acceptSslCerts');
c.get('applicationCacheEnabled');
c.get('browserConnectionEnabled');

Ok, many thanks, I will try that!

I spent some time figuring this out especially I got the same object as above and didnt know how to parse. Here's the updated code for this.

browser.getCapabilities().then(function(c) {
                console.log(c.get('browserName'));
});

Thanks

Was this page helpful?
0 / 5 - 0 ratings