File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed
py/selenium/webdriver/common/bidi Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,15 @@ class ScreenOrientationType(Enum):
3737 LANDSCAPE_SECONDARY = "landscape-secondary"
3838
3939
40+ def _convert_to_enum (value , enum_class ):
41+ if isinstance (value , enum_class ):
42+ return value
43+ try :
44+ return enum_class (value )
45+ except ValueError :
46+ raise ValueError (f"Invalid orientation: { value } " )
47+
48+
4049class ScreenOrientation :
4150 """Represents screen orientation configuration."""
4251
@@ -55,22 +64,9 @@ def __init__(
5564 Raises:
5665 ValueError: If natural or type values are invalid.
5766 """
58- # Convert strings to enums if needed
59- if isinstance (natural , str ):
60- try :
61- self .natural = ScreenOrientationNatural (natural )
62- except ValueError :
63- raise ValueError (f"Invalid natural orientation: { natural } " )
64- else :
65- self .natural = natural
66-
67- if isinstance (type , str ):
68- try :
69- self .type = ScreenOrientationType (type )
70- except ValueError :
71- raise ValueError (f"Invalid orientation type: { type } " )
72- else :
73- self .type = type
67+ # handle string values
68+ self .natural = _convert_to_enum (natural , ScreenOrientationNatural )
69+ self .type = _convert_to_enum (type , ScreenOrientationType )
7470
7571 def to_dict (self ) -> dict [str , str ]:
7672 return {
You can’t perform that action at this time.
0 commit comments