Skip to content

Commit 431aba1

Browse files
authored
feat: add status tentatively (appium#820)
* feat: add status tentatively * update test * fix docstring * fix typo * fix lint
1 parent 0651afc commit 431aba1

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

appium/webdriver/mobilecommand.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class MobileCommand:
1818
GET_SESSION = 'getSession'
1919
GET_ALL_SESSIONS = 'getAllSessions'
2020

21+
GET_STATUS = 'getStatus'
22+
2123
## MJSONWP for Selenium v4
2224
GET_LOCATION = 'getLocation'
2325
SET_LOCATION = 'setLocation'

appium/webdriver/webdriver.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ def start_session(self, capabilities: Union[Dict, AppiumOptions], browser_profil
338338
self.session_id = session_id
339339
self.caps = get_response_value('capabilities') or {}
340340

341+
def get_status(self) -> Dict:
342+
"""
343+
Get the Appium server status
344+
345+
Usage:
346+
driver.get_status()
347+
Returns:
348+
Dict: The status information
349+
350+
"""
351+
return self.execute(Command.GET_STATUS)['value']
352+
341353
def find_element(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = None) -> MobileWebElement:
342354
"""
343355
Find an element given a AppiumBy strategy and locator
@@ -492,6 +504,8 @@ def _add_commands(self) -> None:
492504
# noinspection PyProtectedMember,PyUnresolvedReferences
493505
commands = self.command_executor._commands
494506

507+
commands[Command.GET_STATUS] = ('GET', '/status')
508+
495509
# FIXME: remove after a while as MJSONWP
496510
commands[Command.TOUCH_ACTION] = ('POST', '/session/$sessionId/touch/perform')
497511
commands[Command.MULTI_ACTION] = ('POST', '/session/$sessionId/touch/multi/perform')

test/unit/webdriver/webelement_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323

2424

2525
class TestWebElement(object):
26+
@httpretty.activate
27+
def test_status(self):
28+
driver = android_w3c_driver()
29+
response = {'ready': True, 'message': {'build': {'version': '2.0.0', 'revision': None}}}
30+
httpretty.register_uri(
31+
httpretty.GET,
32+
appium_command('/status'),
33+
body=json.dumps({"value": response}),
34+
)
35+
s = driver.get_status()
36+
37+
assert s == response
38+
2639
@httpretty.activate
2740
def test_set_value(self):
2841
driver = android_w3c_driver()

0 commit comments

Comments
 (0)