Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting unexpected data: {"Error":"InvalidHostID","Request":"StartSession"} while calling driver.device_time #19700

Closed
3 tasks done
vadimnakonechny opened this issue Jan 24, 2024 · 7 comments
Labels
iOS related to iOS native driver(s) ThirdParty upstream problems

Comments

@vadimnakonechny
Copy link

vadimnakonechny commented Jan 24, 2024

Do I have the most recent component updates?

  • I use the most recent available driver/plugin and server versions

Is the component officially supported by the Appium team?

  • I have verified the component repository is present under the Appium organization in GitHub

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Hello, i'm facing the issue while trying to fetch date from the real iOS device using driver.device_time
Environment:
iOS 17.2
Appium - 2.4.1
XCUITest driver - 5.2.0
Python appium version - 1.0.2 because of project policies.
Desired capabilities:
desired_capabilities: dict = { 'automationName': 'XCUITest', 'platformName': 'iOS', 'deviceName': 'Test iPhone', 'platformVersion': '17.2', 'bundleId': 'mu bundle id', 'udid': 'my udid', 'app': APP_PATH, 'xcodeOrgId': 'my xcodeOrgId', 'xcodeSigninId': 'iPhone Developer', 'autoAcceptAlerts': True, 'fullReset': True, 'noReset': False, 'newCommandTimeout': 20000, 'shouldUseSingletonTestManager': False, 'wdaLocalPort': 8101 }

It happens systematically, i have no idea what's the reason for that.
The only thing i think about is that python appium version 1.0.2 is too obsolete.

Traceback:
phone_time = self.__driver.device_time
../../../../../../../Library/Python/3.9/lib/python/site-packages/appium/webdriver/extensions/device_time.py:37: in device_time
return self.execute(Command.GET_DEVICE_TIME_GET, {})['value']
../../../../../../../Library/Python/3.9/lib/python/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute
self.error_handler.check_response(response)
../../../../../../../Library/Python/3.9/lib/python/site-packages/appium/webdriver/errorhandler.py:31: in check_response
raise wde
../../../../../../../Library/Python/3.9/lib/python/site-packages/appium/webdriver/errorhandler.py:26: in check_response
super().check_response(response)


self = <appium.webdriver.errorhandler.MobileErrorHandler object at 0x12638a250>
response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"An unknown server-side error occurred while pro...ncHandler (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:491:57)"}}'}

def check_response(self, response):
    """
    Checks that a JSON response from the WebDriver does not have an error.

    :Args:
     - response - The JSON response from the WebDriver server as a dictionary
       object.

    :Raises: If the response contains an error message.
    """
    status = response.get('status', None)
    if status is None or status == ErrorCode.SUCCESS:
        return
    value = None
    message = response.get("message", "")
    screen = response.get("screen", "")
    stacktrace = None
    if isinstance(status, int):
        value_json = response.get('value', None)
        if value_json and isinstance(value_json, basestring):
            import json
            try:
                value = json.loads(value_json)
                if len(value.keys()) == 1:
                    value = value['value']
                status = value.get('error', None)
                if status is None:
                    status = value["status"]
                    message = value["value"]
                    if not isinstance(message, basestring):
                        value = message
                        message = message.get('message')
                else:
                    message = value.get('message', None)
            except ValueError:
                pass

    exception_class = ErrorInResponseException
    if status in ErrorCode.NO_SUCH_ELEMENT:
        exception_class = NoSuchElementException
    elif status in ErrorCode.NO_SUCH_FRAME:
        exception_class = NoSuchFrameException
    elif status in ErrorCode.NO_SUCH_WINDOW:
        exception_class = NoSuchWindowException
    elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
        exception_class = StaleElementReferenceException
    elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
        exception_class = ElementNotVisibleException
    elif status in ErrorCode.INVALID_ELEMENT_STATE:
        exception_class = InvalidElementStateException
    elif status in ErrorCode.INVALID_SELECTOR \
            or status in ErrorCode.INVALID_XPATH_SELECTOR \
            or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
        exception_class = InvalidSelectorException
    elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
        exception_class = ElementNotSelectableException
    elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
        exception_class = ElementNotInteractableException
    elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
        exception_class = InvalidCookieDomainException
    elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
        exception_class = UnableToSetCookieException
    elif status in ErrorCode.TIMEOUT:
        exception_class = TimeoutException
    elif status in ErrorCode.SCRIPT_TIMEOUT:
        exception_class = TimeoutException
    elif status in ErrorCode.UNKNOWN_ERROR:
        exception_class = WebDriverException
    elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
        exception_class = UnexpectedAlertPresentException
    elif status in ErrorCode.NO_ALERT_OPEN:
        exception_class = NoAlertPresentException
    elif status in ErrorCode.IME_NOT_AVAILABLE:
        exception_class = ImeNotAvailableException
    elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
        exception_class = ImeActivationFailedException
    elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
        exception_class = MoveTargetOutOfBoundsException
    elif status in ErrorCode.JAVASCRIPT_ERROR:
        exception_class = JavascriptException
    elif status in ErrorCode.SESSION_NOT_CREATED:
        exception_class = SessionNotCreatedException
    elif status in ErrorCode.INVALID_ARGUMENT:
        exception_class = InvalidArgumentException
    elif status in ErrorCode.NO_SUCH_COOKIE:
        exception_class = NoSuchCookieException
    elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
        exception_class = ScreenshotException
    elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
        exception_class = ElementClickInterceptedException
    elif status in ErrorCode.INSECURE_CERTIFICATE:
        exception_class = InsecureCertificateException
    elif status in ErrorCode.INVALID_COORDINATES:
        exception_class = InvalidCoordinatesException
    elif status in ErrorCode.INVALID_SESSION_ID:
        exception_class = InvalidSessionIdException
    elif status in ErrorCode.UNKNOWN_METHOD:
        exception_class = UnknownMethodException
    else:
        exception_class = WebDriverException
    if value == '' or value is None:
        value = response['value']
    if isinstance(value, basestring):
        if exception_class == ErrorInResponseException:
            raise exception_class(response, value)
        raise exception_class(value)
    if message == "" and 'message' in value:
        message = value['message']

    screen = None
    if 'screen' in value:
        screen = value['screen']

    stacktrace = None
    if 'stackTrace' in value and value['stackTrace']:
        stacktrace = []
        try:
            for frame in value['stackTrace']:
                line = self._value_or_default(frame, 'lineNumber', '')
                file = self._value_or_default(frame, 'fileName', '<anonymous>')
                if line:
                    file = "%s:%s" % (file, line)
                meth = self._value_or_default(frame, 'methodName', '<anonymous>')
                if 'className' in frame:
                    meth = "%s.%s" % (frame['className'], meth)
                msg = "    at %s (%s)"
                msg = msg % (meth, file)
                stacktrace.append(msg)
        except TypeError:
            pass
    if exception_class == ErrorInResponseException:
        raise exception_class(response, message)
    elif exception_class == UnexpectedAlertPresentException:
        alert_text = None
        if 'data' in value:
            alert_text = value['data'].get('text')
        elif 'alert' in value:
            alert_text = value['alert'].get('text')
        raise exception_class(message, screen, stacktrace, alert_text)
  raise exception_class(message, screen, stacktrace)

E selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Unexpected data: {"Error":"InvalidHostID","Request":"StartSession"}

../../../../../../../Library/Python/3.9/lib/python/site-packages/selenium/webdriver/remote/errorhandler.py:242: WebDriverException

Expected Behavior

driver.device_time returns me current date

Minimal Reproducible Example

No idea, i think issue is specific only for my environment

Environment

No response

Link to Appium Logs

No response

Further Information

No response

@vadimnakonechny vadimnakonechny added Bug a problem that needs fixing Needs Triage bugs which are not yet confirmed labels Jan 24, 2024
@mykola-mokhnach
Copy link
Collaborator

Please provide the server log

@mykola-mokhnach mykola-mokhnach added Needs Info typically non-actionable; needs author to respond and removed Bug a problem that needs fixing Needs Triage bugs which are not yet confirmed labels Jan 24, 2024
@vadimnakonechny
Copy link
Author

vadimnakonechny commented Jan 24, 2024

Logs are below.
Before trying to get the time, iPhone date and time was set to 31 March 2024, 00:59. Those are my test steps.

Time setting

[XCUITestDriver@f415 (1a7ae46a)] Calling AppiumDriver.setValue() with args: [["5","9"],"A1020000-0000-0000-8905-000000000000","1a7ae46a-2d6c-48be-a65a-54536eb173d4"]
[XCUITestDriver@f415 (1a7ae46a)] Executing command 'setValue'
[XCUITestDriver@f415 (1a7ae46a)] Matched '/element/A1020000-0000-0000-8905-000000000000/value' to command name 'setValue'
[XCUITestDriver@f415 (1a7ae46a)] Added 'text' property "59" to 'setValue' request body
[XCUITestDriver@f415 (1a7ae46a)] Proxying [POST /element/A1020000-0000-0000-8905-000000000000/value] to [POST http://127.0.0.1:8101/session/87FE3F56-9F6A-43A8-9A61-4B3C423122AE/element/A1020000-0000-0000-8905-000000000000/value] with body: {"value":["5","9"],"text":"59"}
[XCUITestDriver@f415 (1a7ae46a)] Got response with status 200: {"value":null,"sessionId":"87FE3F56-9F6A-43A8-9A61-4B3C423122AE"}
[XCUITestDriver@f415 (1a7ae46a)] Responding to client with driver.setValue() result: null
[HTTP] <-- POST /wd/hub/session/1a7ae46a-2d6c-48be-a65a-54536eb173d4/element/A1020000-0000-0000-8905-000000000000/value 200 3809 ms - 14
[HTTP] 
[HTTP] --> POST /wd/hub/session/1a7ae46a-2d6c-48be-a65a-54536eb173d4/appium/device/terminate_app
[HTTP] {"appId":"com.apple.Preferences"}
[XCUITestDriver@f415 (1a7ae46a)] Calling AppiumDriver.terminateApp() with args: ["com.apple.Preferences",null,null,null,"1a7ae46a-2d6c-48be-a65a-54536eb173d4"]
[XCUITestDriver@f415 (1a7ae46a)] Executing command 'terminateApp'
[XCUITestDriver@f415 (1a7ae46a)] Proxying [POST /wda/apps/terminate] to [POST http://127.0.0.1:8101/session/87FE3F56-9F6A-43A8-9A61-4B3C423122AE/wda/apps/terminate] with body: {"bundleId":"com.apple.Preferences"}
[XCUITestDriver@f415 (1a7ae46a)] Got response with status 200: {"value":true,"sessionId":"87FE3F56-9F6A-43A8-9A61-4B3C423122AE"}
[XCUITestDriver@f415 (1a7ae46a)] Responding to client with driver.terminateApp() result: true
[HTTP] <-- POST /wd/hub/session/1a7ae46a-2d6c-48be-a65a-54536eb173d4/appium/device/terminate_app 200 1114 ms - 14
[HTTP] 
[HTTP] --> GET /wd/hub/session/1a7ae46a-2d6c-48be-a65a-54536eb173d4/appium/device/system_time
[HTTP] {}

1 minute of sleep in the test and then

[XCUITestDriver@f415 (1a7ae46a)] Calling AppiumDriver.getDeviceTime() with args: [null,"1a7ae46a-2d6c-48be-a65a-54536eb173d4"]
[XCUITestDriver@f415 (1a7ae46a)] Executing command 'getDeviceTime'
[XCUITestDriver@f415 (1a7ae46a)] Attempting to capture iOS device date and time
[XCUITestDriver@f415 (1a7ae46a)] Encountered internal error running command: Error: Unexpected data: {"Error":"InvalidHostID","Request":"StartSession"}
[XCUITestDriver@f415 (1a7ae46a)]     at Lockdown.startSession (/Users/user/node_modules/appium-xcuitest-driver/node_modules/appium-ios-device/lib/lockdown/index.js:47:13)
[XCUITestDriver@f415 (1a7ae46a)]     at startLockdownSession (/Users/user/node_modules/appium-xcuitest-driver/node_modules/appium-ios-device/lib/utilities.js:172:5)
[XCUITestDriver@f415 (1a7ae46a)]     at Object.getDeviceTime (/Users/user/node_modules/appium-xcuitest-driver/node_modules/appium-ios-device/lib/utilities.js:143:20)
[XCUITestDriver@f415 (1a7ae46a)]     at XCUITestDriver.getDeviceTime (/Users/user/node_modules/appium-xcuitest-driver/lib/commands/general.js:85:46)
[HTTP] <-- GET /wd/hub/session/1a7ae46a-2d6c-48be-a65a-54536eb173d4/appium/device/system_time 500 69 ms - 656
[HTTP] 
[HTTP] --> GET /wd/hub/session/1a7ae46a-2d6c-48be-a65a-54536eb173d4/screenshot
[HTTP] {}

@mykola-mokhnach mykola-mokhnach added iOS related to iOS native driver(s) Needs Triage bugs which are not yet confirmed and removed Needs Info typically non-actionable; needs author to respond labels Jan 24, 2024
@vadimnakonechny
Copy link
Author

vadimnakonechny commented Jan 24, 2024

When i just call driver.device_time just after session start - it's working properly and device time is returned

@mykola-mokhnach
Copy link
Collaborator

@tomriddly maybe you have some idea on the above error?

@KazuCocoa
Copy link
Member

it looks like similar to libimobiledevice/libimobiledevice#922 ...? The link addressed idevicepair, so I guess something device paring issue occurred...?

@tomriddly
Copy link

Please make sure you can run WDA from xcode. It seems to be a pair issue.
And for IOS >=17, we could not use imagemounter to solve this for now

@mykola-mokhnach mykola-mokhnach added ThirdParty upstream problems and removed Needs Triage bugs which are not yet confirmed labels Jan 25, 2024
@mykola-mokhnach
Copy link
Collaborator

Closed as third party issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS related to iOS native driver(s) ThirdParty upstream problems
Projects
None yet
Development

No branches or pull requests

4 participants