appium / appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Apache License 2.0
115 stars 24 forks source link

Session Time out after opening the App #264

Open M-Fahad opened 6 months ago

M-Fahad commented 6 months ago

Please help the same code was working before, now I changed the App and it started displaying errors. The App has already been added to the accessibility list as well.

Client code

import pytest
from appium import webdriver
# Options are available in Python client since v2.6.0
from appium.options.mac import Mac2Options
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.common.by import By
import time

options = Mac2Options()
options.bundle_id = 'com.devicework.app'
# The default URL is http://127.0.0.1:4723/wd/hub in Appium1
drv = webdriver.Remote('http://127.0.0.1:4723', options=options)
time.sleep(30)
print ("Hello")
drv.quit()

Server Logs

Last login: Wed Jan  3 14:33:45 on ttys001
upgenics@Upgenicss-MacBook-Pro-2 ~ % appium
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver espresso...
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-espresso-driver
[Appium] Attempting to load driver xcuitest...
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver gecko...
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-geckodriver
[Appium] Attempting to load driver chromium...
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-chromium-driver
[Appium] Attempting to load driver mac2...
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-mac2-driver
[Appium] Attempting to load driver uiautomator2...
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-uiautomator2-driver
(node:1164) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLS in your client code to connect to this server:
[Appium]    http://127.0.0.1:4723/ (only accessible from the same host)
[Appium]    http://192.168.3.155:4723/
[Appium] Available drivers:
[Appium]   - espresso@2.29.0 (automationName 'Espresso')
[Appium]   - xcuitest@5.8.1 (automationName 'XCUITest')
[Appium]   - gecko@1.2.7 (automationName 'Gecko')
[Appium]   - chromium@1.2.33 (automationName 'Chromium')
[Appium]   - mac2@1.8.6 (automationName 'Mac2')
[Appium]   - uiautomator2@2.34.0 (automationName 'UiAutomator2')
[Appium] Available plugins:
[Appium]   - images@2.1.6
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
[debug] [HTTP] Request idempotency key: 35540870-6011-49f0-b8c6-2dd2ecda98d9
[HTTP] --> POST /session
[HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Mac2","platformName":"Mac","appium:bundleId":"com.devicework.app"}}}
[debug] [AppiumDriver@666e] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Mac2","platformName":"Mac","appium:bundleId":"com.devicework.app"}}]
[debug] [AppiumDriver@666e] Event 'newSessionRequested' logged at 1704274845820 (14:40:45 GMT+0500 (Pakistan Standard Time))
[Appium] Attempting to find matching driver for automationName 'Mac2' and platformName 'Mac'
[Appium] The 'mac2' driver was installed and matched caps.
[Appium] Will require it at /Users/upgenics/.appium/node_modules/appium-mac2-driver
[debug] [Appium] Requiring driver at /Users/upgenics/.appium/node_modules/appium-mac2-driver
[AppiumDriver@666e] Appium v2.0.1 creating new Mac2Driver (v1.8.6) session
[AppiumDriver@666e] Checking BaseDriver versions for Appium and Mac2Driver
[AppiumDriver@666e] Appium's BaseDriver version is 9.4.2
[AppiumDriver@666e] Mac2Driver's BaseDriver version is 9.3.15
[debug] [Mac2Driver@8d8c] Creating session with W3C capabilities: {
[debug] [Mac2Driver@8d8c]   "alwaysMatch": {
[debug] [Mac2Driver@8d8c]     "platformName": "Mac",
[debug] [Mac2Driver@8d8c]     "appium:automationName": "Mac2",
[debug] [Mac2Driver@8d8c]     "appium:bundleId": "com.devicework.app"
[debug] [Mac2Driver@8d8c]   },
[debug] [Mac2Driver@8d8c]   "firstMatch": [
[debug] [Mac2Driver@8d8c]     {}
[debug] [Mac2Driver@8d8c]   ]
[debug] [Mac2Driver@8d8c] }
[Mac2Driver@8d8c (e78b74ce)] Session created with session id: e78b74ce-0ed3-46fe-b416-e38cde49def8
[debug] [WebDriverAgentMac] Using bootstrap root: /Users/upgenics/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac
[debug] [WebDriverAgentMac] Using xcodebuild binary at '/usr/bin/xcodebuild'
[WebDriverAgentMac] Performing project cleanup
[debug] [WebDriverAgentMac] Using 127.0.0.1 as server host
[debug] [WebDriverAgentMac] Using port 10100
[WebDriverAgentMac] Mac2Driver host process logging is disabled. All the xcodebuild output is going to be suppressed. Set the 'showServerLogs' capability to 'true' if this is an undesired behavior
[WebDriverAgentMac] Starting Mac2Driver host process: xcodebuild build-for-testing test-without-building -project /Users/upgenics/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE\=NO
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:10100/status] with no body
[debug] [WD Proxy] Got response with status 200: {"value":{"message":"WebDriverAgent is ready to accept commands","state":"success","os":{"version":"Version 11.6.6 (Build 20G624)"},"ready":true,"build":{"time":"Jan  3 2024 14:40:52"}},"sessionId":null}
[WebDriverAgentMac] The host process is ready within 9238ms
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:10100/session] with body: {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"platformName":"Mac","automationName":"Mac2","bundleId":"com.devicework.app"}}}
[WD Proxy] AxiosError: timeout of 240000ms exceeded
[WD Proxy]     at RedirectableRequest.handleRequestTimeout (/Users/upgenics/node_modules/axios/lib/adapters/http.js:628:16)
[WD Proxy]     at RedirectableRequest.emit (node:events:527:28)
[WD Proxy]     at Timeout.<anonymous> (/Users/upgenics/node_modules/follow-redirects/index.js:169:12)
[WD Proxy]     at listOnTimeout (node:internal/timers:564:17)
[WD Proxy]     at processTimers (node:internal/timers:507:7)
[debug] [AppiumDriver@666e] Event 'newSessionStarted' logged at 1704275097622 (14:44:57 GMT+0500 (Pakistan Standard Time))
[debug] [AppiumDriver@666e] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded
[debug] [AppiumDriver@666e]     at WDAMacProxy.command (/Users/upgenics/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
[debug] [AppiumDriver@666e]     at runNextTicks (node:internal/process/task_queues:60:5)
[debug] [AppiumDriver@666e]     at listOnTimeout (node:internal/timers:533:9)
[debug] [AppiumDriver@666e]     at processTimers (node:internal/timers:507:7)
[debug] [AppiumDriver@666e]     at WDAMacServer.startSession (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/wda-mac.js:444:5)
[debug] [AppiumDriver@666e]     at Mac2Driver.createSession (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/driver.js:110:7)
[debug] [AppiumDriver@666e]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:352:35)
[HTTP] <-- POST /session 500 251841 ms - 1019
[HTTP] 

Client-side logs

Last login: Wed Jan  3 14:40:00 on ttys000
upgenics@Upgenicss-MacBook-Pro-2 ~ % cd Desktop/appium-mac2-driver-master/Example
upgenics@Upgenicss-MacBook-Pro-2 Example % python3 TestE.py 
Traceback (most recent call last):
  File "/Users/upgenics/Desktop/appium-mac2-driver-master/Example/TestE.py", line 16, in <module>
    drv = webdriver.Remote('http://127.0.0.1:4723', options=options)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/appium/webdriver/webdriver.py", line 229, in __init__
    super().__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/appium/webdriver/webdriver.py", line 321, in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded
    at WDAMacProxy.command (/Users/upgenics/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:533:9)
    at processTimers (node:internal/timers:507:7)
    at WDAMacServer.startSession (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/wda-mac.js:444:5)
    at Mac2Driver.createSession (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/driver.js:110:7)
    at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:352:35)
upgenics@Upgenicss-MacBook-Pro-2 Example % 
LykashevichAndrei commented 6 months ago

Today we face the same issue with our solution.

in our case, this issue is reproducible only if we want to connect to application that is started as a sub process of build from development code.

if we use binary file and trying to connect to it sub process everything works fine.