Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PaddyMann opened this issue Mar 18, 2016 · 8 comments
Closed

Comments

@PaddyMann
Copy link

@PaddyMann PaddyMann commented Mar 18, 2016

  • 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?

@juliemr

This comment has been minimized.

Copy link
Member

@juliemr juliemr commented Mar 18, 2016

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.

@juliemr

This comment has been minimized.

Copy link
Member

@juliemr juliemr commented Mar 18, 2016

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.

@juliemr juliemr closed this Mar 18, 2016
@PaddyMann

This comment has been minimized.

Copy link
Author

@PaddyMann PaddyMann commented Mar 21, 2016

Thanks Julie - appreciated :)

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

@yamafaktory

This comment has been minimized.

Copy link
Contributor

@yamafaktory yamafaktory commented Apr 4, 2016

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)?

@PaddyMann

This comment has been minimized.

Copy link
Author

@PaddyMann PaddyMann commented Apr 4, 2016

@yamafaktory

Use (e.g.):

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

This comment has been minimized.

Copy link
Contributor

@yamafaktory yamafaktory commented Apr 4, 2016

Ok, many thanks, I will try that!

@writetocynthia

This comment has been minimized.

Copy link

@writetocynthia writetocynthia commented Jul 15, 2016

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'));
});
@numanWD

This comment has been minimized.

Copy link

@numanWD numanWD commented Jul 27, 2016

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.