Skip to content

desired_capabilities doesn't appear to work for local WebDrivers #139

Closed

Description

@lesliepc16

It doesn't look like the desired capabilities flag is working when opening a chrome browser. I think it might be related to this change in the selenium library.
http://code.google.com/p/selenium/source/diff?spec=svn18044&r=17342&format=side&path=/trunk/py/selenium/webdriver/chrome/webdriver.py&old_path=/trunk/py/selenium/webdriver/chrome/webdriver.py&old=17055

Using keyword Open browser as follows:
Open browser ${url} browser=chrome desired_capabilities=--enable-logging:,--v:1

And then in the log:
DEBUG POST http://127.0.0.1:49881/session {"sessionId": null, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true, "chromeOptions": {"binary": "", "args": [], "extensions": []}}}

Activity

  1. j1z0 commented on Nov 2, 2012

    @j1z0
    Contributor

    Chrome's just gotta be different doesn't it. :) Thanks for pointing this out. We'll have to rework the Open Browser code.

    Cheers,
    Jeremy

    On Nov 2, 2012, at 5:09 AM, lesliepc16 wrote:

    It doesn't look like the desired capabilities flag is working when opening a chrome browser. I think it might be related to this change in the selenium library.
    http://code.google.com/p/selenium/source/diff?spec=svn18044&r=17342&format=side&path=/trunk/py/selenium/webdriver/chrome/webdriver.py&old_path=/trunk/py/selenium/webdriver/chrome/webdriver.py&old=17055

    Using keyword Open browser as follows:
    Open browser ${url} browser=chrome desired_capabilities=--enable-logging:,--v:1

    And then in the log:
    DEBUG POST http://127.0.0.1:49881/session {"sessionId": null, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true, "chromeOptions": {"binary": "", "args": [], "extensions": []}}}

    —
    Reply to this email directly or view it on GitHub.

  2. lesliepc16 commented on Nov 2, 2012

    @lesliepc16
    Author

    Hey Jeremy,

    Right after posting this, I saw that a 2.26.0 version of selenium was
    posted and it appears they re-added desired capabilities. So it's possible
    it'll work again if people upgrade to this. I haven't had a chance to try
    yet because I'm having trouble upgrading to 2.26.0

    http://code.google.com/p/selenium/source/browse/trunk/py/selenium/webdriver/chrome/webdriver.py
    http://code.google.com/p/selenium/source/detail?r=17953&path=/trunk/py/selenium/webdriver/chrome/webdriver.py

    -L

    On Thu, Nov 1, 2012 at 8:31 PM, Jeremy Johnson notifications@github.life-white.ukwrote:

    Chrome's just gotta be different doesn't it. :) Thanks for pointing this
    out. We'll have to rework the Open Browser code.

    Cheers,
    Jeremy

    On Nov 2, 2012, at 5:09 AM, lesliepc16 wrote:

    It doesn't look like the desired capabilities flag is working when
    opening a chrome browser. I think it might be related to this change in the
    selenium library.

    http://code.google.com/p/selenium/source/diff?spec=svn18044&r=17342&format=side&path=/trunk/py/selenium/webdriver/chrome/webdriver.py&old_path=/trunk/py/selenium/webdriver/chrome/webdriver.py&old=17055

    Using keyword Open browser as follows:
    Open browser ${url} browser=chrome
    desired_capabilities=--enable-logging:,--v:1

    And then in the log:
    DEBUG POST http://127.0.0.1:49881/session {"sessionId": null,
    "desiredCapabilities": {"platform": "ANY", "browserName": "chrome",
    "version": "", "javascriptEnabled": true, "chromeOptions": {"binary": "",
    "args": [], "extensions": []}}}

    —
    Reply to this email directly or view it on GitHub.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/139#issuecomment-10003939.

  3. j1z0 commented on Nov 2, 2012

    @j1z0
    Contributor

    ahh ok, let me know the outcome if / when you get a chance to upgrade. If it works we will just have to change the setup dependencies to be >= 2.26.0

  4. lesliepc16 commented on Nov 2, 2012

    @lesliepc16
    Author

    Not sure if I'm doing something wrong, but after upgrading to 2.26.0 this still isn't working for me.

    Ran a simple test case:
    (Note github is stripping out some of my extra spaces that I have between args and stuff so I added dots.)


    _Settings_
    Library.....Selenium2Library

    _Test Cases_
    Start Chrome
    .....Start Chrome

    _Keywords_
    Start Chrome.....Open browser.....http://www.google.com.....browser=Chrome.....desired_capabilities=--enable-logging:


    Then in the log I don't see the desired capabilities.

    13:44:07.235 TRACE Arguments: [ u'http://www.google.com' | desired_capabilities=u'--enable-logging:' | browser=u'Chrome' ]
    13:44:07.235 INFO Opening browser 'Chrome' to base url 'http://www.google.com'
    13:44:08.241 DEBUG POST http://127.0.0.1:51201/session {"sessionId": null, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true, "chromeOptions": {"binary": "", "args": [], "extensions": []}}}

  5. j1z0 commented on Nov 3, 2012

    @j1z0
    Contributor

    well desired capabilities should be a dictionary. So I don't think that --enable-logging: is the correct syntax. It's probably something like enable-logging:True. I'll have a go when I get back to my normal machine on Monday and let you know if it works for me.

    Cheers,
    Jeremy

    On Nov 3, 2012, at 4:53 AM, lesliepc16 wrote:

    Not sure if I'm doing something wrong, but after upgrading to 2.26.0 this still isn't working for me.

    Ran a simple test case:

    Settings
    Library.....Selenium2Library

    Test Cases
    Start Chrome
    .....Start Chrome

    Keywords
    Start Chrome.....Open browser.....http://www.google.com.....browser=Chrome.....desired_capabilities=--enable-logging:

    Then in the log I don't see the desired capabilities. (Before I upgraded to 2.25, it actually complained about

    13:44:07.235 TRACE Arguments: [ u'http://www.google.com' | desired_capabilities=u'--enable-logging:' | browser=u'Chrome' ]
    13:44:07.235 INFO Opening browser 'Chrome' to base url 'http://www.google.com'
    13:44:08.241 DEBUG POST http://127.0.0.1:51201/session {"sessionId": null, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true, "chromeOptions": {"binary": "", "args": [], "extensions": []}}}

    Note github is stripping out some of my extra spaces that I have between args and stuff so I added dots.

    —
    Reply to this email directly or view it on GitHub.

  6. lesliepc16 commented on Nov 6, 2012

    @lesliepc16
    Author

    Hey Jeremy,

    I couldn't find any good documentation on how to pass this, but skimming this it seemed like the dictionary would correspond to the chrome command line switches:
    http://code.google.com/p/selenium/wiki/ChromeDriver

  7. peritus commented on Jan 28, 2013

    @peritus
    Contributor

    Here's what I think happens:

    You pass

    desired_capabilities=--enable-logging:,--v:1
    

    and selenium2library parses that to the JSON (in https://github.com/rtomac/robotframework-selenium2library/blob/master/src/Selenium2Library/keywords/_browsermanagement.py#L463) that is then send to Selenium:

    {"--enable-logging": "", "--v": "1"}
    

    However, what you want is setting the capability "chrome.switches" to the Value ["enable-logging", "v=1"] (values Chrome accepts here are documented at https://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches), so selenium2library should send

    {"chrome.switches": ["enable-logging", "v=1"]}
    

    to Selenium.


    By looking at the code, I don't think selenium2library is currently able to send this desired_capability configuration object to Selenium, because it is limited to simple string-only key-value-pairs.

    Because Robot Framework has support for dictionaries and lists, I'd propose to let desired_capabilities to also accept real dictonaries in addition to the special-formatted strings like it is implemented right now (should also be backwards compatible):

    *** Settings ***
    Library    Collections
    
    *** Test Cases ***
    
    Complex Desired Capabilities Should Work
        ${chrome_switches} =         Create List          enable-logging       v=1
        ${desired_capabilities} =    Create Dictionary    chrome.switches      ${chrome_switches}     platform    WINDOWS
        Open Browser                 *googlechrome        desired_capabilities=${desired_capabilities}
    

    .. how about that ?

  8. j1z0 commented on Jan 29, 2013

    @j1z0
    Contributor

    Makes sense to me. Will we need to do something rethinking of the whole thing anyways cause the Chrome boys are depreciating desired capabilities altogether.... So much for standardization. :(

    Cheers,
    Jeremy

    On Jan 28, 2013, at 21:00, Filip Noetzel notifications@github.com wrote:

    Here's what I think happens:

    You pass

    desired_capabilities=--enable-logging:,--v:1
    and selenium2library parses that to the JSON (in https://github.com/rtomac/robotframework-selenium2library/blob/master/src/Selenium2Library/keywords/_browsermanagement.py#L463) that is then send to Selenium:

    {"--enable-logging": "", "--v": "1"}
    However, what you want is setting the capability "chrome.switches" to the Value ["enable-logging", "v=1"](values Chrome accepts here are documented at https://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches), so selenium2library should send

    {"chrome.switches": ["enable-logging", "v=1"]}
    to Selenium.

    By looking at the code, I don't think selenium2library is currently able to send this desired_capability configuration object to Selenium, because it is limited to simple string-only key-value-pairs.

    Because Robot Framework has support for dictionaries and lists, I'd propose to let desired_capabilities to also accept real dictonaries in addition to the special-formatted strings like it is implemented right now (should also be backwards compatible):

    *** Settings ***
    Library Collections

    *** Test Cases ***

    Complex Desired Capabilities Should Work
    ${chrome_switches} = Create List enable-logging v=1
    ${desired_capabilities} = Create Dictionary chrome.switches ${chrome_switches} platform WINDOWS
    Open Browser *googlechrome desired_capabilities=${desired_capabilities}
    .. how about that ?

    —
    Reply to this email directly or view it on GitHub.

  9. peritus commented on Jan 29, 2013

    @peritus
    Contributor

    @j1z0 Do you have a pointer to some wiki page / mailing list discussion about the deprecation plans ?

    I think I'll get around to a pull request implementing my proposal in the next days, so we at least have something that works until it's deprecated.

  10. j1z0 commented on Jan 31, 2013

    @j1z0
    Contributor

    U believe I saw it in the code itself, but I can't remember for sure. I checked the docs page and it doesn't say anything about getting rid of desired capabilities. So perhaps I'm being a bit premature. However the new one us called ChromeOptions and functions similar to desired capabilities. You might want to google a bit. Sorry I can't be more helpful but I'm a bit limited being that I'm on my phone right now.

    Cheers,
    Jeremy

    On Jan 29, 2013, at 19:21, Filip Noetzel notifications@github.com wrote:

    @j1z0 Do you have a pointer to some wiki page / mailing list discussion about the deprecation plans ?

    I think I'll get around to a pull request implementing my proposal in the next days, so we at least have something that works until it's deprecated.

    —
    Reply to this email directly or view it on GitHub.

  11. changed the title [-]Desired Capabilities doesn't appear to work[/-] [+]desired_capabilities doesn't appear to work for local WebDrivers[/+] on Aug 29, 2014
  12. aaltat commented on Nov 5, 2015

    @aaltat
    Contributor

    I think this is now possible with the Create Webdriver keyword. If you think that this is still an issue, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions