appium / appium-mac2-driver

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

Server connections issue #256

Closed M-Fahad closed 7 months ago

M-Fahad commented 7 months ago

Hi,

I am running this script but unable to connect with the server, please help how to fix.

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

options = Mac2Options()
options.bundle_id = 'com.apple.TextEdit'
# 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)
drv.quit()

Server response is

Last login: Wed Nov 22 13:24:18 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:6502) 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.4.39: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: 7e451159-d80a-4151-8ba4-70a8bf3d7b62
[HTTP] --> POST /session
[HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Mac2","platformName":"Mac","appium:bundleId":"com.apple.TextEdit"}}}
[debug] [AppiumDriver@ed70] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Mac2","platformName":"Mac","appium:bundleId":"com.apple.TextEdit"}}]
[debug] [AppiumDriver@ed70] Event 'newSessionRequested' logged at 1700648570909 (15:22:50 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@ed70] Appium v2.0.1 creating new Mac2Driver (v1.8.6) session
[AppiumDriver@ed70] Checking BaseDriver versions for Appium and Mac2Driver
[AppiumDriver@ed70] Appium's BaseDriver version is 9.4.2
[AppiumDriver@ed70] Mac2Driver's BaseDriver version is 9.3.15
[debug] [Mac2Driver@dada] Creating session with W3C capabilities: {
[debug] [Mac2Driver@dada]   "alwaysMatch": {
[debug] [Mac2Driver@dada]     "platformName": "Mac",
[debug] [Mac2Driver@dada]     "appium:automationName": "Mac2",
[debug] [Mac2Driver@dada]     "appium:bundleId": "com.apple.TextEdit"
[debug] [Mac2Driver@dada]   },
[debug] [Mac2Driver@dada]   "firstMatch": [
[debug] [Mac2Driver@dada]     {}
[debug] [Mac2Driver@dada]   ]
[debug] [Mac2Driver@dada] }
[Mac2Driver@dada (7d8a5eb9)] Session created with session id: 7d8a5eb9-e463-4f43-be50-83722d11d20a
[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
[WebDriverAgentMac] Cannot perform project cleanup. Original error: xcrun: error: active developer path ("/Users/upgenics/Downloads/Xcode.app/Contents/Developer") does not exist
[WebDriverAgentMac] Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
[WebDriverAgentMac] See `man xcode-select` for more details.
[WebDriverAgentMac] 
[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
[WebDriverAgentMac] Mac2Driver host process has exited with code 1, signal null
[WebDriverAgentMac] Mac2Driver session cannot be stopped, because the server is not running
[debug] [AppiumDriver@ed70] Event 'newSessionStarted' logged at 1700648572012 (15:22:52 GMT+0500 (Pakistan Standard Time))
[debug] [AppiumDriver@ed70] Encountered internal error running command: Error: An unknown server-side error occurred while processing the command. Original error: 'GET /status' cannot be proxied to Mac2 Driver server because its process is not running (probably crashed). Check the Appium log for more details
[debug] [AppiumDriver@ed70]     at WDAMacServer.isProxyReady (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/wda-mac.js:316:15)
[debug] [AppiumDriver@ed70]     at waitMs (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/wda-mac.js:412:44)
[debug] [AppiumDriver@ed70]     at spin (/Users/upgenics/.appium/node_modules/appium-mac2-driver/node_modules/asyncbox/lib/asyncbox.js:219:20)
[debug] [AppiumDriver@ed70]     at spin (/Users/upgenics/.appium/node_modules/appium-mac2-driver/node_modules/asyncbox/lib/asyncbox.js:229:14)
[debug] [AppiumDriver@ed70]     at waitForCondition (/Users/upgenics/.appium/node_modules/appium-mac2-driver/node_modules/asyncbox/lib/asyncbox.js:236:10)
[debug] [AppiumDriver@ed70]     at WDAMacServer.startSession (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/wda-mac.js:412:9)
[debug] [AppiumDriver@ed70]     at Mac2Driver.createSession (/Users/upgenics/.appium/node_modules/appium-mac2-driver/lib/driver.js:110:7)
[debug] [AppiumDriver@ed70]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:352:35)
[HTTP] <-- POST /session 500 1160 ms - 960
[HTTP] 

Client terminal resposne is

Last login: Wed Nov 22 15:20:39 on ttys000
upgenics@Upgenicss-MacBook-Pro-2 ~ % cd Desktop/appium-mac2-driver-master/Example/python3 TestE.py
cd: string not in pwd: Desktop/appium-mac2-driver-master/Example/python3
upgenics@Upgenicss-MacBook-Pro-2 ~ % cd Desktop/appium-mac2-driver-master/Example                
upgenics@Upgenicss-MacBook-Pro-2 Example % pyhton3 TestE.py
zsh: command not found: pyhton3
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 13, 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 318, 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: An unknown server-side error occurred while processing the command. Original error: 'GET /status' cannot be proxied to Mac2 Driver server because its process is not running (probably crashed). Check the Appium log for more details
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: An unknown server-side error occurred while processing the command. Original error: 'GET /status' cannot be proxied to Mac2 Driver server because its process is not running (probably crashed). Check the Appium log for more details
    at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1097:9)
    at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:491:57)
upgenics@Upgenicss-MacBook-Pro-2 Example % 
KazuCocoa commented 7 months ago
[WebDriverAgentMac] Cannot perform project cleanup. Original error: xcrun: error: active developer path ("/Users/upgenics/Downloads/Xcode.app/Contents/Developer") does not exist
[WebDriverAgentMac] Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
[WebDriverAgentMac] See `man xcode-select` for more details.
[WebDriverAgentMac] 

Did you set sudo xcode-select --switch path/to/Xcode.app? It seems like /Users/upgenics/Downloads/Xcode.app/Contents/Developer does not exist.

M-Fahad commented 7 months ago

@KazuCocoa Thanks, it's working now. I have another question, if possible please assist me. I am automating the Mac application which is developed in Java. how can I find elements? Is there any way to find elements? I tried with Appium Inspector but it's not working perfectly. I think Appium inspector is only for Mobile Apps.

KazuCocoa commented 7 months ago

Usually Appium/mac2 driver can find elements that is available in the result of driver.page_source. So elements that are not in the page source result, this driver cannot interact with them as probably XCTest framework by Apple cannot parse them.