[py][bidi]: add set_screen_orientation_override command in Emulation - #16522
Conversation
PR Compliance Guide 🔍(Compliance updated until commit 861195b)Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label Previous compliance checksCompliance check up to commit 5326081
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
|
@cgoldberg could you review this? Thanks! |
|
Could we add some .lower() safeties for setting with strings - will prevent errors like accidentally writing "Landscape" instead of "landscape"? imo it's better to be defensive. PR is safe to merge either way though, nice work! |
User description
🔗 Related Issues
💥 What does this PR do?
Adds the
set_screen_orientation_overridecommand to the Emulation module - https://w3c.github.io/webdriver-bidi/#command-emulation-setScreenOrientationOverride.🔧 Implementation Notes
Usage:
Using ENUM:
Using strings:
💡 Additional Considerations
Supported by both chromium and Firefox.
We can set the natural orientation and the type via ENUMs or through strings directly.
_convert_to_enuminternally converts str to enum and raises value error if wrong string is passed.🔄 Types of changes
PR Type
Enhancement
Description
Adds
set_screen_orientation_overridecommand to Emulation moduleImplements
ScreenOrientationclass with enum supportSupports both enum and string-based orientation configuration
Includes comprehensive tests for contexts and user contexts
Diagram Walkthrough
File Walkthrough
emulation.py
Implement screen orientation override functionalitypy/selenium/webdriver/common/bidi/emulation.py
ScreenOrientationNaturalandScreenOrientationTypeenums fororientation values
_convert_to_enum()helper function to convert strings toenums with validation
ScreenOrientationclass to encapsulate natural and typeorientation settings
set_screen_orientation_override()method to apply orientationoverrides to contexts or user contexts
provided, but not both
bidi_emulation_tests.py
Add comprehensive screen orientation override testspy/test/selenium/webdriver/common/bidi_emulation_tests.py
ScreenOrientation,ScreenOrientationNatural, andScreenOrientationTypeget_screen_orientation()helper function to retrievecurrent screen orientation and angle
test_set_screen_orientation_override_with_contexts()to testorientation changes with browsing contexts
test_set_screen_orientation_override_with_user_contexts()covering allorientation combinations