Sitelet https://github.com/appium/python-client/commit/1162bab613a3418b6f9b4d2cdb5e41dfebd28ede
Skip to content

Commit 1162bab

Browse files
authored
fix(webdriver): normalize orientation value to uppercase in setter (#1308)
1 parent 90c38d1 commit 1162bab

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎appium/webdriver/webdriver.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def orientation(self, value: str) -> None:
458458
"""
459459
allowed_values = ['LANDSCAPE', 'PORTRAIT']
460460
if value.upper() in allowed_values:
461-
self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value})
461+
self.execute(Command.SET_SCREEN_ORIENTATION, {'orientation': value.upper()})
462462
else:
463463
raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'")
464464

‎test/unit/webdriver/webdriver_test.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,21 @@ def test_orientation_setter(self):
486486
'orientation': 'PORTRAIT',
487487
}
488488

489+
@httpretty.activate
490+
def test_orientation_setter_normalizes_case(self):
491+
driver = android_w3c_driver()
492+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/orientation'), body='{"value": ""}')
493+
494+
driver.orientation = 'landscape'
495+
assert get_httpretty_request_body(httpretty.last_request()) == {
496+
'orientation': 'LANDSCAPE',
497+
}
498+
499+
driver.orientation = 'portrait'
500+
assert get_httpretty_request_body(httpretty.last_request()) == {
501+
'orientation': 'PORTRAIT',
502+
}
503+
489504
@httpretty.activate
490505
def test_orientation_setter_invalid(self):
491506
driver = android_w3c_driver()

0 commit comments

Comments
 (0)