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

Python first/always logic in the client doesn't work with arrays as values #9538

Closed
shs96c opened this issue Jun 2, 2021 · 2 comments
Closed
Labels
Milestone

Comments

@shs96c
Copy link
Member

shs96c commented Jun 2, 2021

🐛 Bug Report

The python first/always logic in the python client doesn't successfully handle the case where capability values are arrays

To Reproduce

from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver import FirefoxOptions

alternative_1 = FirefoxOptions()
alternative_1.set_capability("vendor:sameList", [])

alternative_2 = FirefoxOptions()
alternative_2.set_capability("vendor:sameList", [])

WebDriver(options=[alternative_1, alternative_2])

Expected behavior

Everything works as expected

Actual behavior

/Users/bob/.pyenv/versions/selenium/bin/python /blah/blah/blah/selenium/try.py
Traceback (most recent call last):
  File "/blah/blah/blah/selenium/try.py", line 8, in <module>
    WebDriver(options=[alternative_1, alternative_2])
  File "/Users/bob/.pyenv/versions/selenium/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 224, in __init__
    capabilities = create_matches(options)
  File "/Users/bob/.pyenv/versions/selenium/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 133, in create_matches
    samesies.update(opts[min_index].items() & opts[i + 1].items())
TypeError: unhashable type: 'list'

Test script or set of commands reproducing this issue

See above

Environment

OS: macOS
Browser: Firefox
Browser version: n/a
Browser Driver version: n/a
Language Bindings version: pre-beta4
Selenium Grid version (if applicable): n/a

@shs96c shs96c added the C-py label Jun 2, 2021
@shs96c shs96c added this to the 4.0 milestone Jun 2, 2021
@AutomatedTester
Copy link
Member

Looking at this it only seems to appear when the list is empty. I can recreate the issue when I do the following test

def test_can_set_multiple_options_with_different_arrays():
    from selenium.webdriver.firefox.options import Options as FirefoxOptions

    expected = {
        "capabilities": {
            "alwaysMatch": {
                "browserName": "firefox",
                "pageLoadStrategy": "normal",
                "platform": "ANY",
                "version": ""
            },
            "firstMatch": [
                {
                    "vendor:sameList": []
                },
                {
                    "vendor:sameList": []
                }
            ]
        }
    }
    alternative_1 = FirefoxOptions()
    alternative_1.set_capability("vendor:sameList", [])

    alternative_2 = FirefoxOptions()
    alternative_2.set_capability("vendor:sameList", [])

    result = webdriver.create_matches([alternative_1, alternative_2])

    assert result == expected

However, a similar test that populates an array is passing as we can see in the test in https://github.com/SeleniumHQ/selenium/blob/trunk/py/test/unit/selenium/webdriver/remote/new_session_tests.py#L76-L100 so wonder if there is a bug in python here or at least my understanding of how the union code should work in the python standard library

@github-actions
Copy link

github-actions bot commented Sep 5, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants