diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 5410409e..add39593 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -458,7 +458,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 33123043..925b013d 100644 --- a/test/unit/webdriver/webdriver_test.py +++ b/test/unit/webdriver/webdriver_test.py @@ -486,6 +486,21 @@ def test_orientation_setter(self): 'orientation': 'PORTRAIT', } + @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_orientation_setter_invalid(self): driver = android_w3c_driver()