Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ permissions:

jobs:
release:
# Releases are cut from the upstream repository only. Without this guard the
# workflow also runs on forks, where semantic-release rewrites the version in
# pyproject.toml, commits to the default branch and attempts a PyPI upload.
if: github.repository == 'appium/python-client'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Expand Down
32 changes: 32 additions & 0 deletions test/unit/webdriver/webdriver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
from unittest.mock import patch

import httpretty
import pytest
import urllib3
from selenium.common.exceptions import WebDriverException

from appium import webdriver
from appium.options.android import UiAutomator2Options
Expand Down Expand Up @@ -512,6 +514,36 @@ def test_get_client_config_and_connection_custom_appium_connection(self):
assert command_executor._client_config != client_config
assert client_config is None

@httpretty.activate
def test_orientation(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.GET,
appium_command('/session/1234567890/orientation'),
body=json.dumps({'value': 'PORTRAIT'}),
)
assert driver.orientation == 'PORTRAIT'

@httpretty.activate
def test_set_orientation(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/orientation'),
body=json.dumps({'value': 'LANDSCAPE'}),
)
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_set_orientation_invalid(self):
driver = android_w3c_driver()
with pytest.raises(WebDriverException, match="You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'"):
driver.orientation = 'INVALID'


class SubWebDriver(WebDriver):
def __init__(self, command_executor, options=None):
Expand Down
Loading