[py][bidi]: implement bidi module - emulation by navin772 · Pull Request #15819 · SeleniumHQ/selenium
User description
🔗 Related Issues
💥 What does this PR do?
Adds support for the emulation module in python bindings - https://w3c.github.io/webdriver-bidi/#module-emulation
🔧 Implementation Notes
Usage:
-
From
contexts:from selenium.webdriver.common.bidi.emulation import GeolocationCoordinates context_id = driver.current_window_handle coords = GeolocationCoordinates(45.5, -122.4194, accuracy=10.0) driver.emulation.set_geolocation_override(coordinates=coords, contexts=[context_id])
-
From
user_contexts:from selenium.webdriver.common.bidi.emulation import GeolocationCoordinates user_context = driver.browser.create_user_context() context_id = driver.browsing_context.create(type=WindowTypes.TAB, user_context=user_context) driver.switch_to.window(context_id) coords = GeolocationCoordinates(45.5, -122.4194, accuracy=10.0, altitude=100.2, altitude_accuracy=5.0, heading=183.2, speed=10.0) driver.emulation.set_geolocation_override(coordinates=coords, user_contexts=[user_context])
Important
Either user_contexts or contexts should be passed, both cannot coexist.
💡 Additional Considerations
The tests need the BiDi permissions module to grant the geolocation permission in order to fetch them.
Note
Currently, when the Error parameter is passed, it is returning an error invalid argument: Invalid input in "coordinates, hence the test is commented out for now.
It is fixed in chrome canary.
🔄 Types of changes
- New feature (non-breaking change which adds functionality and tests!)
PR Type
Enhancement
Description
• Implement BiDi emulation module for Python bindings
• Add geolocation override functionality with coordinates support
• Include comprehensive test coverage for contexts and user contexts
• Support multiple browsing contexts and user contexts
Changes walkthrough 📝
| Relevant files | |||||
|---|---|---|---|---|---|
| Enhancement |
| ||||
| Tests |
|
Need help?
Type /help how to ...in the comments thread for any questions about Qodo Merge usage.Check out the documentation for more information.