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
The event wait uses a fixed 5s timeout and checks only that at least one event arrived; consider increasing robustness by asserting specific event fields after wait and handling potential multiple events or navigation delays.
The test asserts only the first event contains the expected URL; if multiple events are fired (e.g., from initial navigation), ensure the assertion searches through all received events to avoid false negatives.
Validate the event corresponds to the current context to avoid flakiness in multi-context environments. Filter to the matching context_id before asserting URL.
assert len(events_received) >= 1
-assert "/new-path" in events_received[0].url-assert events_received[0].context == context_id+matching = [e for e in events_received if e.context == context_id]+assert matching, "No history_updated event for the current context"+assert "/new-path" in matching[0].url
Apply / Chat
Suggestion importance[1-10]: 7
__
Why: The suggestion improves the assertion logic by filtering events by context_id before checking their properties, making the test more robust against flakiness from other concurrent browsing contexts.
Medium
Add explicit wait failure message
Guard against hanging waits by adding a timeout-safe condition and raise a clear assertion if the event doesn't arrive. Use an explicit message to aid debugging when the event fails to fire.
-WebDriverWait(driver, 5).until(lambda d: len(events_received) > 0)+WebDriverWait(driver, 5).until(+ lambda d: len(events_received) > 0,+ message="Timed out waiting for history_updated event"+)
Apply / Chat
Suggestion importance[1-10]: 5
__
Why: This is a good practice suggestion that improves the test's maintainability by adding a descriptive message to the WebDriverWait, which aids in debugging test failures.
Low
Possible issue
Target script to correct context
Ensure the BiDi script is executed in the correct browsing context. Pass the explicit target so the script runs in the current window when multiple contexts exist, avoiding missed events.
Why: The suggestion correctly recommends explicitly setting the target context for script.execute, which enhances the test's robustness by preventing potential ambiguity in multi-context environments.
Low
Learned best practice
Validate event data before use
Guard against empty or malformed event payloads before indexing into the list and accessing fields. Validate that the first event exists and contains the expected attributes to prevent intermittent IndexError or AttributeError.
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?
Enables the
history_updatedevent test - https://w3c.github.io/webdriver-bidi/#event-browsingContext-historyUpdated for chrome, edge and firefox. Stable versions of these browsers now support this event.🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Tests
Description
Enable
history_updatedevent test for Chrome, Edge, and FirefoxUpdate test implementation to use BiDi script execution
Add explicit wait for event handling
Remove browser-specific xfail markers
Diagram Walkthrough
File Walkthrough
bidi_browsing_context_tests.py
Enable history_updated event test across browserspy/test/selenium/webdriver/common/bidi_browsing_context_tests.py
execute_scriptto BiDiscript.execute