10000 feat: add status tentatively by KazuCocoa · Pull Request #820 · appium/python-client · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
2 changes: 2 additions & 0 deletions appium/webdriver/mobilecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class MobileCommand:
GET_SESSION = 'getSession'
GET_ALL_SESSIONS = 'getAllSessions'

GET_STATUS = 'getStatus'

## MJSONWP for Selenium v4
GET_LOCATION = 'getLocation'
SET_LOCATION = 'setLocation'
Expand Down
14 changes: 14 additions & 0 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@ def start_session(self, capabilities: Union[Dict, AppiumOptions], browser_profil
self.session_id = session_id
self.caps = get_response_value('capabilities') or {}

def get_status(self) -> Dict:
"""
Get the Appium server status

Usage:
driver.get_status()
Returns:
Dict: The status information

"""
return self.execute(Command.GET_STATUS)['value']

def find_element(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> MobileWebElement:
"""
Find an element given a AppiumBy strategy and locator
Expand Down Expand Up @@ -492,6 +504,8 @@ def _add_commands(self) -> None:
# noinspection PyProtectedMember,PyUnresolvedReferences
commands = self.command_executor._commands

commands[Command.GET_STATUS] = ('GET', '/status')

# FIXME: remove after a while as MJSONWP
commands[Command.TOUCH_ACTION] = ('POST', '/session/$sessionId/touch/perform')
commands[Command.MULTI_ACTION] = ('POST', '/session/$sessionId/touch/multi/perform')
Expand Down
13 changes: 13 additions & 0 deletions test/unit/webdriver/webelement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@


class TestWebElement(object):
@httpretty.activate
def test_status(self):
driver = android_w3c_driver()
response = {'ready': True, 'message': {'build': {'version': '2.0.0', 'revision': None}}}
httpretty.register_uri(
httpretty.GET,
appium_command('/status'),
body=json.dumps({"value": response}),
)
s = driver.get_status()

assert s == response

@httpretty.activate
def test_set_value(self):
driver = android_w3c_driver()
Expand Down
0