refactor(tab): separate execute_script concerns #258
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.
Refactoring Pull Request
Refactoring Scope
The Tab class's
execute_script
method inpydoll/browser/tab.py
, related tests and documentation.Related Issue(s)
Addresses user feedback from GitHub Discussion #108 regarding async script execution capabilities
Description
Refactor the
execute_script
method by separating concerns to improve the API design. The new implementation should support asynchronous execution usingawait_promise=True
andreturn_by_value=True
, provide additional options for flexible usage in code. The original method handled both general script execution and element-specific execution, which has been split into two focused methods:execute_script
: Enhanced with comprehensive runtime options for general script executionexecute_element_script
: New method specifically for executing scripts with element contextMotivation
Support for asynchronous code.
Before / After
Before
After
Performance Impact
Technical Debt
This refactoring addresses several technical debt issues:
API Changes
Testing Strategy
Testing Checklist
Risks and Mitigations
execute_script(script, element)
signatureChecklist before requesting a review
poetry run task lint
and fixed any issuespoetry run task test
and all tests pass