You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
• Fix "Error: ConnectFailure (Connection refused)" when instantiating Chrome Driver multiple times
Requires further human verification:
• Issue occurs on Ubuntu 16.04.4 with Chrome 65.0.3325.181 and ChromeDriver 2.35
• First instance works fine, but subsequent instances fail with connection errors
The code validates permission states but doesn't validate permission names or origins. Consider adding validation for descriptor names and origin format to prevent invalid inputs.
ifstatenotin [PermissionState.GRANTED, PermissionState.DENIED, PermissionState.PROMPT]:
valid_states=f"{PermissionState.GRANTED}, {PermissionState.DENIED}, {PermissionState.PROMPT}"raiseValueError(f"Invalid permission state. Must be one of: {valid_states}")
Tests focus on geolocation permission only. Consider adding tests for other common permission types (camera, microphone, notifications) to ensure broader functionality coverage.
deftest_can_set_permission_to_granted(driver, pages):
"""Test setting permission to granted state."""pages.load("blank.html")
origin=get_origin(driver)
# Set geolocation permission to granteddriver.permissions.set_permission("geolocation", PermissionState.GRANTED, origin)
result=get_geolocation_permission(driver)
assertresult==PermissionState.GRANTEDdeftest_can_set_permission_to_denied(driver, pages):
"""Test setting permission to denied state."""pages.load("blank.html")
origin=get_origin(driver)
# Set geolocation permission to denieddriver.permissions.set_permission("geolocation", PermissionState.DENIED, origin)
result=get_geolocation_permission(driver)
assertresult==PermissionState.DENIEDdeftest_can_set_permission_to_prompt(driver, pages):
"""Test setting permission to prompt state."""pages.load("blank.html")
origin=get_origin(driver)
# First set to denied, then to prompt since most of the time the default state is promptdriver.permissions.set_permission("geolocation", PermissionState.DENIED, origin)
driver.permissions.set_permission("geolocation", PermissionState.PROMPT, origin)
result=get_geolocation_permission(driver)
assertresult==PermissionState.PROMPT
The test doesn't handle potential failures in the BiDi connection setup. Add error handling to ensure the test fails gracefully if BiDi features aren't available in the current browser or driver configuration.
def test_can_set_permission_for_user_context(driver, pages):
"""Test setting permission for a specific user context."""
+ # Skip if BiDi is not available+ if not hasattr(driver, 'browser') or not hasattr(driver, 'browsing_context'):+ pytest.skip("BiDi support not available")+
# Create a user context
user_context = driver.browser.create_user_context()
context_id = driver.browsing_context.create(type=WindowTypes.TAB, user_context=user_context)
Apply / Chat
Suggestion importance[1-10]: 5
__
Why: This is a reasonable error handling suggestion that adds BiDi availability checks to prevent test failures. However, it's an error handling improvement that provides defensive programming rather than fixing a critical issue.
//py:common-firefox-bidi-test/selenium/webdriver/common/driver_element_finding_tests.py FLAKY, failed in 1 out of 2 in 600.3s
Stats over 2 runs: max = 600.3s, min = 571.2s, avg = 585.8s, dev = 14.6s
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-firefox-bidi-test/selenium/webdriver/common/driver_element_finding_tests.py/test_attempts/attempt_1.log
//py:common-chrome-bidi-test/selenium/webdriver/common/devtools_tests.py FAILED in 2 out of 2 in 17.6s
Stats over 2 runs: max = 17.6s, min = 17.2s, avg = 17.4s, dev = 0.2s
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-chrome-bidi-test/selenium/webdriver/common/devtools_tests.py/test.log
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-chrome-bidi-test/selenium/webdriver/common/devtools_tests.py/test_attempts/attempt_1.log
//py:common-edge-bidi-test/selenium/webdriver/common/devtools_tests.py FAILED in 2 out of 2 in 17.4s
Stats over 2 runs: max = 17.4s, min = 17.1s, avg = 17.3s, dev = 0.2s
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-edge-bidi-test/selenium/webdriver/common/devtools_tests.py/test.log
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-edge-bidi-test/selenium/webdriver/common/devtools_tests.py/test_attempts/attempt_1.log
//py:common-firefox-bidi-test/selenium/webdriver/common/webdriverwait_tests.py FAILED in 2 out of 2 in 302.5s
Stats over 2 runs: max = 302.5s, min = 301.1s, avg = 301.8s, dev = 0.7s
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-firefox-bidi-test/selenium/webdriver/common/webdriverwait_tests.py/test.log
/home/runner/.bazel/execroot/_main/bazel-out/k8-fastbuild/testlogs/py/common-firefox-bidi-test/selenium/webdriver/common/webdriverwait_tests.py/test_attempts/attempt_1.log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
🔗 Related Issues
💥 What does this PR do?
Adds support for the permissions module in python - https://www.w3.org/TR/permissions/#automation-webdriver-bidi
🔧 Implementation Notes
Currently, I am supporting the permission name input in 2 ways:
PermissionDescriptorobject:💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Implements BiDi permissions module in Python bindings
Adds
PermissionsAPI to WebDriver for BiDi commandsProvides comprehensive tests for permissions functionality
Supports both string and descriptor-based permission setting
Changes walkthrough 📝
permissions.py
Add BiDi permissions module implementationpy/selenium/webdriver/common/bidi/permissions.py
PermissionStateandPermissionDescriptorclassesPermissionsclass for BiDi permission commandswebdriver.py
Integrate BiDi permissions API into WebDriverpy/selenium/webdriver/remote/webdriver.py
Permissionsmodulepermissionsproperty to WebDriver for BiDi accessbidi_permissions_tests.py
Add tests for BiDi permissions modulepy/test/selenium/webdriver/common/bidi_permissions_tests.py