question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open Browser fails if desired capabilities is a dict

See original GitHub issue

This issue goes away if you revert to SeleniumLibrary 3.2.0

Steps to reproduce the issue

*** Settings ***
Library    SeleniumLibrary
*** Test Cases ***
Repro
    ${caps}    Create Dictionary    javascriptEnabled=${True}
    Open Browser    https://www.google.com    desired_capabilities=${caps}

Error messages and additional information

Starting test: SL-bug.DesiredCapabilitiesBug.Repro
20190102 14:57:16.375 : TRACE : Arguments: [ 'javascriptEnabled=${True}' ]
20190102 14:57:16.376 : TRACE : Return: {'javascriptEnabled': True}
20190102 14:57:16.376 : INFO : ${caps} = {u'javascriptEnabled': True}
20190102 14:57:16.377 : TRACE : Arguments: [ 'https://www.google.com' | desired_capabilities={'javascriptEnabled': True} ]
20190102 14:57:16.377 : INFO : Opening browser 'firefox' to base url 'https://www.google.com'.
20190102 14:57:16.379 : TRACE : Arguments: [  ]
20190102 14:57:16.380 : INFO : Cannot capture screenshot because no browser is open.
20190102 14:57:16.380 : TRACE : Return: None
20190102 14:57:16.382 : FAIL : TypeError: __init__() got an unexpected keyword argument 'javascriptEnabled'
20190102 14:57:16.382 : DEBUG : Traceback (most recent call last):
  File "/ws/SL-bug/venv/lib/python2.7/site-packages/SeleniumLibrary/__init__.py", line 372, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "/ws/SL-bug/venv/lib/python2.7/site-packages/SeleniumLibrary/base/robotlibcore.py", line 102, in run_keyword
    return self.keywords[name](*args, **kwargs)
  File "/ws/SL-bug/venv/lib/python2.7/site-packages/SeleniumLibrary/keywords/browsermanagement.py", line 131, in open_browser
    ff_profile_dir, remote_url)
  File "/ws/SL-bug/venv/lib/python2.7/site-packages/SeleniumLibrary/keywords/browsermanagement.py", line 456, in _make_driver
    remote_url=remote, profile_dir=profile_dir)
  File "/ws/SL-bug/venv/lib/python2.7/site-packages/SeleniumLibrary/keywords/webdrivertools.py", line 58, in create_driver
    profile_dir)
  File "/ws/SL-bug/venv/lib/python2.7/site-packages/SeleniumLibrary/keywords/webdrivertools.py", line 109, in create_firefox
    **desired_capabilities)
Ending test: SL-bug.DesiredCapabilitiesBug.Repro

Expected behavior and actual behavior

When I follow those steps, keyword fails

I was expecting browser to open

Environment

Browser: Any Browser driver: Any Operating System: macOS 10.13.2 Libraries

  • Robot Framework: 3.1
  • Selenium: 3.141.0
  • SeleniumLibrary: 3.3.0
  • Interpreter: CPython 2.7.15

This was be caused by https://github.com/robotframework/SeleniumLibrary/commit/159206fbe62b7189f893f5e4d60b47eaacd4b700#diff-566132cdf5a534d7e99598e5acc77378. _parse_capabilities returns the capabilities as is when they are dict. But it needs to return keyword args as it does for string type desired capabilities or Falsey desired capabilities.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ombre42commented, Jan 3, 2019

Thanks so much for the quick turnaround. I did pip install git+https://github.com/robotframework/SeleniumLibrary.git. Then I changed the test such that it requires the caps to work (go to site behind a proxy).

    ${caps}    Evaluate    {"proxy": {"proxyType": "manual", "socksProxy": "localhost:3130", "socksVersion": 5}}
    Open Browser    https://somehost/    chrome    desired_capabilities=${caps}

Worked like a charm.

0reactions
aaltatcommented, Jan 2, 2019

This issue should be fixed now in the master branch. @ombre42 could install from master and try it out? I will make hotfix release, but would like to wait few days so that more people have time to try 3.3.0 out and discover other possible regression bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to set desired capabilities when calling Open Browser ...
I am unable to call the keyword Open Browser when specifying desired capabilities for IE. I'm not sure if its a syntax issue, ......
Read more >
Test different browser locales in Chrome with Desired ...
Test different browser locales in Chrome with Desired Capabilities. Chrome sets a default UI language with the first Chrome window that opens.
Read more >
selenium/webdriver/remote/webdriver.py - external/selenium/py
desired_capabilities - Dictionary holding predefined values for starting a browser. - browser_profile - A selenium.webdriver.firefox.firefox_profile.
Read more >
Help with Selenium2Library's "create webdriver" keyword and ...
I'm not able to specify a URL when using the "remote" driver. My keyword looks like this: *** Keywords ***. open app. ${capabilities}=...
Read more >
Capabilities and EdgeOptions - Microsoft Edge Development
List of command-line arguments that WebView2 will pass to the browser process on launch. Arguments with an associated value should be separated ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found