Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Python Webdriver chrome_options vs desired_capabilities #7389

Closed
lukeis opened this issue Mar 4, 2016 · 11 comments
Closed

Python Webdriver chrome_options vs desired_capabilities #7389

lukeis opened this issue Mar 4, 2016 · 11 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 7389

Before filing an issue, please read the page at
http://code.google.com/p/selenium/wiki/SeleniumHelp This contains lot of
information about how best to get help, and tells you what we need to know.

Still here? We know that bugs are frustrating and annoying things. We also
know that you've probably spent ages trying to figure out what's wrong. The
more information you give us now, the more likely it is that we'll be able
to help.

What steps will reproduce the problem?
Launch a webdriver.Chrome with chrome_options and desired_capabilities.  In particular,
include a *subkey* in desired_capabilities, like desired_capabilities["chromeOptions"]["excludeSwitches"]

What is the expected output? What do you see instead?

I would expect Chrome to be launched respecting the subkey passed to chromeOptions.

When the chrome_options are merged into the desired_capabilities, subkeys are instead
overwritten, because it is a shallow dictionary update, not a deep merge.

Specifically, any value specified in desired_capabilities["chromeOptions"]["excludeSwitches"]
is overwritten when a new Options().to_capabilities is merged on top, overwriting the
whole chromeOptions subkey

For more detail, see script.py here: https://gist.github.com/jasonm/b5e3f58203eb253204f7

I think a fix to this file:
https://code.google.com/p/selenium/source/browse/py/selenium/webdriver/chrome/webdriver.py

Would look something like these lines:
https://gist.github.com/jasonm/b5e3f58203eb253204f7#file-selenium-webdriver-chrome-webdriver-py-L47-L57

Selenium version: python selenium 2.42.0
OS: Mac OS
Browser: Chrome
Browser version: 35

Please provide any additional information below. A sample reduced test
case, or a public URL that demonstrates the problem will intrigue our merry
band of Open Source developers far more than nothing at all: they'll be far
more likely to look at your problem if you make it easy for them!

Reported by jmorrison@minervaproject.com on 2014-05-23 22:49:33

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

My proposed fix at the end is just one way that fixes my specific issue.  I'm not sure
the desired merge behavior when passing chrome_options and desired_capabilities - maybe
a more sophisticated deep merge is desired.

Reported by jmorrison@minervaproject.com on 2014-05-23 22:50:35

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by andreas.tolf.tolfsen on 2014-05-27 22:00:38

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

i think the intention has always been to not mix the two, if you are trying to set a
Chrome Option, you should be doing so on the options passed in and not trying to directly
do so on the desired capabilities (in fact requiring you to follow a 'best practice'
by using the Options instead)

That being said, i'm not opposed to the patch and will gladly merge it once you confirm
that you've signed the CLA:  http://goo.gl/qC50R

Reported by luke.semerau on 2014-05-27 22:19:41

  • Status changed: Accepted

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi Luke - Signed the CLA.  Keeping the two option sets distinct makes the most sense
to me, too.  In that case should it raise an ArgumentError/etc if both are None?

Reported by jmorrison@minervaproject.com on 2014-05-27 22:50:03

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Sorry, rather should it raise if both are *not* None

Reported by jmorrison@minervaproject.com on 2014-05-27 22:50:58

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue was closed by revision 6a7bb83aaea4.

Reported by luke.semerau on 2014-05-27 23:05:11

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

thanks for the patch... I'm not inclined to have an exception raised though :)

Reported by luke.semerau on 2014-05-27 23:05:39

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Thanks Luke!

Reported by jmorrison@minervaproject.com on 2014-05-27 23:09:44

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Should this commit be included in the 2.42.1 release?

From the rev history it looks like it should be (your commit 6a7bb83 is an ancestor
of the 2.42.1 release commit 68b415adb11a) :
https://code.google.com/p/selenium/source/list

But the 2.42.1 package on PyPI doesn't appear to contain it:
https://gist.github.com/jasonm/bb610408edf9df852cb8

Reported by jmorrison@minervaproject.com on 2014-05-29 18:13:16

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Nevermind - I missed the separate 4502e40a974 "Bumping python to 2.42.1"

Reported by jmorrison@minervaproject.com on 2014-05-29 18:14:17

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:22:29

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant