Skip to content

Using desired_capabilities affects future sessions #217

Closed

Description

@ombre42

When desired_capabilities is passed to Open Browser, the default DesiredCapabilities object for the requested browser (which is a class attribute) is changed for the remainder of the test run. Unfortunately, the Selenium project's examples for Python demonstrate doing it that way.
I will submit a pull request to address this issue.
If instead we took a copy of the default desired capabilities object and manipulated that, this would not be an issue. A deep copy would safeguard against default capabilities with nested dicts.

In the following set of test cases, Second will use the proxy setup in First, even if they reside in different suites. You can see this in the output of Open Browser in Second if you run with log level DEBUG:
20130625 16:49:20.017 : DEBUG : POST http://127.0.0.1:4444/wd/hub/session {"sessionId": null, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "proxy": {"proxyType": "MANUAL", "httpProxy": "localhost:8888"}, "javascriptEnabled": true}}

First
    ${chrome dc}=    Evaluate    selenium.webdriver.DesiredCapabilities.CHROME    selenium
    Dictionary Should Not Contain Key    ${chrome dc}    proxy
    ${desired capabilities}=    Evaluate    {'proxy': {'proxyType': 'MANUAL', 'httpProxy': 'localhost:8888'}}
    Open Browser    http://www.google.com/    gc    remote_url=http://localhost:4444/wd/hub    desired_capabilities=${desired capabilities}
    [Teardown]    Close Browser

Second
    ${chrome dc}=    Evaluate    selenium.webdriver.DesiredCapabilities.CHROME    selenium
    Run Keyword And Continue On Failure    Dictionary Should Not Contain Key    ${chrome dc}    proxy
    Open Browser    http://www.msn.com/    gc    remote_url=http://localhost:4444/wd/hub
    [Teardown]    Close Browser

Activity

  1. ombre42 commented on Dec 28, 2013

    @ombre42
    ContributorAuthor

    This may be fixed upstream. Selenium team is considering returning a copy of the desired capabilities dict in this issue. Since this issue was discovered in code analysis and not reported by users and may be fixed upstream, moving to 1.6.

  2. ombre42 commented on Dec 29, 2013

    @ombre42
    ContributorAuthor

    Looks like Selenium team thinks users should work with a copy of the desired capabilities. Since a Selenium2Library user does not really have a choice, we should always work with a copy. If a capability is required in every browser opened in the same session, then is must be specified in every call to Open Browser.

  3. added a commit that references this issue on Dec 31, 2013
    5d42571
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions