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
• Added timestamp parameter to HistoryUpdatedParams constructor • Updated from_json method to parse and validate timestamp • Added validation ensuring timestamp is non-negative integer • Updated class to match WebDriver BiDi specification
• Fix JavaScript execution in link href on click() method
• Ensure JavaScript alerts are triggered when clicking links with JavaScript in href
• Restore functionality that worked in version 2.47.1 but broke in 2.48.0/2.48.2
• Fix compatibility with Firefox 42.0
The addition of a new required parameter to the constructor and validation logic lacks corresponding unit tests to verify the timestamp validation behavior and proper instantiation.
def__init__(
self,
context: str,
timestamp: int,
url: str,
):
self.context=contextself.timestamp=timestampself.url=url@classmethoddeffrom_json(cls, json: dict) ->"HistoryUpdatedParams":
"""Creates a HistoryUpdatedParams instance from a dictionary. Parameters: ----------- json: A dictionary containing the history updated parameters. Returns: ------- HistoryUpdatedParams: A new instance of HistoryUpdatedParams. """context=json.get("context")
ifcontextisNoneornotisinstance(context, str):
raiseValueError("context is required and must be a string")
timestamp=json.get("timestamp")
iftimestampisNoneornotisinstance(timestamp, int) ortimestamp<0:
raiseValueError("timestamp is required and must be a non-negative integer")
url=json.get("url")
ifurlisNoneornotisinstance(url, str):
raiseValueError("url is required and must be a string")
returncls(
context=context,
timestamp=timestamp,
url=url,
)
Add type validation for the timestamp parameter in the constructor to ensure consistency with the from_json method. This prevents invalid timestamp values from being passed directly to the constructor.
def __init__(
self,
context: str,
timestamp: int,
url: str,
):
+ if not isinstance(timestamp, int) or timestamp < 0:+ raise ValueError("timestamp must be a non-negative integer")
self.context = context
self.timestamp = timestamp
self.url = url
Apply / Chat
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that validation for the timestamp parameter is only performed in the from_json method. Adding the same validation to the __init__ constructor ensures that HistoryUpdatedParams objects are always created in a valid state, regardless of whether they are instantiated directly or through the factory method. This improves the robustness and consistency of the class.
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 the
timestampparameter toHistoryUpdatedParamsclass as per the updated bidi spec - https://w3c.github.io/webdriver-bidi/#event-browsingContext-historyUpdated🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
• Add
timestampparameter toHistoryUpdatedParamsclass• Update constructor and JSON parsing method
• Add validation for timestamp parameter
• Align with updated WebDriver BiDi specification
Changes walkthrough 📝
browsing_context.py
Add timestamp parameter to HistoryUpdatedParamspy/selenium/webdriver/common/bidi/browsing_context.py
• Added
timestampparameter toHistoryUpdatedParamsconstructor•
Updated
from_jsonmethod to parse and validate timestamp• Added
validation ensuring timestamp is non-negative integer
• Updated class
to match WebDriver BiDi specification