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()