From 505ee66b73f1427a659453fb4cb18d8155ff5faa Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sat, 5 Sep 2026 10:21:48 +0200 Subject: [PATCH] fix(webdriver): normalize orientation value to uppercase in setter --- appium/webdriver/webdriver.py | 2 +- test/unit/webdriver/webdriver_test.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 4584824b..6ca1867c 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -431,7 +431,7 @@ def orientation(self, value: str) -> None: """ allowed_values = ['LANDSCAPE', 'PORTRAIT'] if value.upper() in allowed_values: - self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value}) + self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value.upper()}) else: raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'") diff --git a/test/unit/webdriver/webdriver_test.py b/test/unit/webdriver/webdriver_test.py index 36102735..1ccaedd9 100644 --- a/test/unit/webdriver/webdriver_test.py +++ b/test/unit/webdriver/webdriver_test.py @@ -404,6 +404,21 @@ class CustomAppiumConnection(AppiumConnection): assert isinstance(driver.command_executor, CustomAppiumConnection) + @httpretty.activate + def test_orientation_setter_normalizes_case(self): + driver = android_w3c_driver() + httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/orientation'), body='{"value": ""}') + + driver.orientation = 'landscape' + assert get_httpretty_request_body(httpretty.last_request()) == { + 'orientation': 'LANDSCAPE', + } + + driver.orientation = 'portrait' + assert get_httpretty_request_body(httpretty.last_request()) == { + 'orientation': 'PORTRAIT', + } + @httpretty.activate def test_extention_command_check(self): driver = android_w3c_driver()