[py][bidi]: add BiDi script module commands
User description
🔗 Related Issues
💥 What does this PR do?
Adds the low level API commands for the Script module - https://w3c.github.io/webdriver-bidi/#module-script
🔧 Implementation Notes
I have only implemented the commonly used types like EvaluateResult, RealmInfo, RealmType, Source and ResultOwnership. Other types are very nested and not required to be implemented explicitly, we can directly pass them as dict.
💡 Additional Considerations
This PR adds the low level APIs only, I will open another PR that adds the remaining High level BiDi script APIs:
pin()unpin()execute()addDomMutationHandler()removeDomMutationHandler()
🔄 Types of changes
- New feature (non-breaking change which adds functionality and tests!)
PR Type
Enhancement, Tests
Description
-
Add BiDi script module commands to Python bindings
- Implement low-level API for script module (evaluate, callFunction, disown, etc.)
- Add support for preload scripts, realms, and result ownership
- Provide dataclasses for script-related types (RealmInfo, EvaluateResult, etc.)
-
Add comprehensive tests for BiDi script module
- Test all new script commands and options (preload, disown, serialization, user activation, etc.)
- Validate error handling and edge cases for script APIs
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.
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
|
🎫 Ticket compliance analysis ❌ 1234 - Not compliant Non-compliant requirements: • Fix issue where JavaScript in link's href is not triggered on click() in Selenium 2.48 • Ensure compatibility with Firefox 42.0 • Restore functionality that worked in version 2.47.1 5678 - Not compliant Non-compliant requirements: • Fix ChromeDriver ConnectFailure error on Ubuntu 16.04.4 • Resolve connection refused errors for subsequent ChromeDriver instances • Ensure first ChromeDriver instance works without console errors |
| ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪ |
| 🧪 PR contains tests |
| 🔒 No security concerns identified |
⚡ Recommended focus areas for reviewParameter Validation
|
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| Possible issue |
✅
| Medium |
| ||
@shbenzer thanks for the review! I have one doubt, currently the low level APIs implemented in this PR are available via the driver instance like - driver.script.add_preload_script(js_script).
I am planning to add these high level APIs for the script module:
pin()unpin()execute()addDomMutationHandler()removeDomMutationHandler()
These will also be available via the same driver instance - driver.script.pin(), is that good or should we do something else? I don't want to make the low-level API private since those can be used by users/other projects that uses selenium.
@shbenzer thanks for the review! I have one doubt, currently the low level APIs implemented in this PR are available via the driver instance like -
driver.script.add_preload_script(js_script).I am planning to add these high level APIs for the script module:
pin()unpin()execute()addDomMutationHandler()removeDomMutationHandler()These will also be available via the same driver instance -
driver.script.pin(), is that good or should we do something else? I don't want to make the low-level API private since those can be used by users/other projects that uses selenium.
methods prepended with _ are marked as private in python but are still accessible
methods prepended with _ are marked as private in python but are still accessible
yes, they are accessible, but I am not sure if that's a nice way to access the low level API, since we are not doing the _ private marking in other modules.
I used _ in the Network module, but I’m definitely open to other suggestions
@shbenzer I will add the _ prefix to make them low level API. Other option might be to add a prefix like bidi_add_preload_script() but since we already use _ in other module, it should be consistent.
The //java/test/org/openqa/selenium/bidi/storage:StorageCommandsTest-edge test is failing in the CI and recent runs on trunk which is unrelated to this PR.
I tried debugging the test but it is passing locally. Probably a Edge browser version issue.