diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index 334f4710c..2a83f1a41 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -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' diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 00f0eaf9f..2866b9e9f 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -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 @@ -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') diff --git a/test/unit/webdriver/webelement_test.py b/test/unit/webdriver/webelement_test.py index 59464fd89..168a8ba0a 100644 --- a/test/unit/webdriver/webelement_test.py +++ b/test/unit/webdriver/webelement_test.py @@ -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()