appium / appium-mac2-driver

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

ECONNREFUSED 127.0.0.1:10100 #215

Closed sksang closed 10 months ago

sksang commented 10 months ago

I am not able to launch the Activity Monitor. Here are the installation versions: Python: 3.11.4 Appium-Python-Client = 2.11.1 Selenium = 4.11.2 appium version = 2.0.1 MacOS: Ventura 13.3 Xcode: 14.3.1

Followed All the Requirements on ReadMe.

Here is my python code `from appium import webdriver

desired_capabilities = { 'platform': 'Mac', 'device_name': 'Mac', 'platformName': 'Mac', 'automationName': 'Mac2', 'commandDelay': 50, 'loopDelay': 0, 'mouseMoveSpeed': 60, 'diagnosticsDirectoryLocation': '~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation' }

driver = webdriver.Remote(command_executor="http://localhost:4723", desired_capabilities=desired_capabilities) driver.get("/System/Applications/Utilities/Activity Monitor.app")`

Here is the Appium log: [Appium] Welcome to Appium v2.0.1 (REV 98f1be77f93a0d23fbc68629d0854522e9f0c1c3) [Appium] Attempting to load driver mac2... [debug] [Appium] Requiring driver at /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver [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.1.4:4723/ [Appium] Available drivers: [Appium] - mac2@1.6.3 (automationName 'Mac2') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. [debug] [HTTP] Request idempotency key: b8b019b3-f50a-46a9-a9b1-2557fb4fcd9e [HTTP] --> POST /session [HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:platform":"Mac","appium:device_name":"Mac","platformName":"Mac","appium:automationName":"Mac2","appium:commandDelay":50,"appium:loopDelay":0,"appium:mouseMoveSpeed":60,"appium:diagnosticsDirectoryLocation":"~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation"}}} [debug] [AppiumDriver@ec7e] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:platform":"Mac","appium:device_name":"Mac","platformName":"Mac","appium:automationName":"Mac2","appium:commandDelay":50,"appium:loopDelay":0,"appium:mouseMoveSpeed":60,"appium:diagnosticsDirectoryLocation":"~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation"}}] [debug] [AppiumDriver@ec7e] Event 'newSessionRequested' logged at 1691649687944 (12:11:27 GMT+0530 (India 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/saurabhkoli/.appium/node_modules/appium-mac2-driver [debug] [Appium] Requiring driver at /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver [AppiumDriver@ec7e] Appium v2.0.1 creating new Mac2Driver (v1.6.3) session [AppiumDriver@ec7e] Checking BaseDriver versions for Appium and Mac2Driver [AppiumDriver@ec7e] Appium's BaseDriver version is 9.3.16 [AppiumDriver@ec7e] Mac2Driver's BaseDriver version is 9.3.16 [debug] [Mac2Driver@dde7] Creating session with W3C capabilities: { [debug] [Mac2Driver@dde7] "alwaysMatch": { [debug] [Mac2Driver@dde7] "platformName": "Mac", [debug] [Mac2Driver@dde7] "appium:platform": "Mac", [debug] [Mac2Driver@dde7] "appium:device_name": "Mac", [debug] [Mac2Driver@dde7] "appium:automationName": "Mac2", [debug] [Mac2Driver@dde7] "appium:commandDelay": 50, [debug] [Mac2Driver@dde7] "appium:loopDelay": 0, [debug] [Mac2Driver@dde7] "appium:mouseMoveSpeed": 60, [debug] [Mac2Driver@dde7] "appium:diagnosticsDirectoryLocation": "~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation" [debug] [Mac2Driver@dde7] }, [debug] [Mac2Driver@dde7] "firstMatch": [ [debug] [Mac2Driver@dde7] {} [debug] [Mac2Driver@dde7] ] [debug] [Mac2Driver@dde7] } [Mac2Driver@dde7] The following capabilities were provided, but are not recognized by Appium: [Mac2Driver@dde7] platform [Mac2Driver@dde7] device_name [Mac2Driver@dde7] commandDelay [Mac2Driver@dde7] loopDelay [Mac2Driver@dde7] mouseMoveSpeed [Mac2Driver@dde7] diagnosticsDirectoryLocation [Mac2Driver@dde7 (2dd265e7)] Session created with session id: 2dd265e7-7266-4787-af7e-b33658e5837f [debug] [WebDriverAgentMac] Using bootstrap root: /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac [debug] [WebDriverAgentMac] Using xcodebuild binary at '/usr/bin/xcodebuild' [WebDriverAgentMac] There is no need to perform the project cleanup. A fresh install has been detected [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/saurabhkoli/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE\=NO [WebDriverAgentMac] Mac2Driver host process has exited with code 1, signal null [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

Please help me as the automation setup was working fine earlier and stopped working now after I have gone furhter in my automation framework.

KazuCocoa commented 10 months ago

What is the result of the below xcodebuild?

xcodebuild build-for-testing test-without-building -project /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE=NO

As the log message, showServerLogs also help to print the xcodebuild result in the appium log as well

sksang commented 10 months ago

Hi @KazuCocoa , Here is the result: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

KazuCocoa commented 10 months ago

Have you configured Xcode env and https://github.com/appium/appium-mac2-driver#requirements ?

Your env may need to set the xcode-select as:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

(to make the xcodebuild work as part of Xcode setup)

sksang commented 10 months ago

I replayed the above command. sudo xcode-select -s /Applications/Xcode.app/Contents/Developer and then replayed the xcodebuild build-for-testing test-without-building -project /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE=NO

And below is the result: ` TEST BUILD SUCCEEDED

--- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:macOS, arch:arm64, id:00008103-000655E23402201E } { platform:macOS, arch:x86_64, id:00008103-000655E23402201E } { platform:macOS, name:Any Mac } Testing started 2023-08-10 12:50:21.284540+0530 WebDriverAgentRunner-Runner[1528:29882] Running tests... Test Suite 'All tests' started at 2023-08-10 12:50:21.734 Test Suite 'WebDriverAgentRunner.xctest' started at 2023-08-10 12:50:21.735 Test Suite 'UITestingUITests' started at 2023-08-10 12:50:21.735 t = nans Suite Set Up Test Case '-[UITestingUITests testRunner]' started. t = 0.00s Start Test at 2023-08-10 12:50:21.736 t = 0.02s Set Up 2023-08-10 12:50:21.756208+0530 WebDriverAgentRunner-Runner[1528:29882] Built at Aug 10 2023 12:50:18 2023-08-10 12:50:21.762897+0530 WebDriverAgentRunner-Runner[1528:29882] ServerURLHere->http://localhost:10100<-ServerURLHere ^C

*** If you believe this error represents a bug, please attach the result bundle at /Users/saurabhkoli/Library/Developer/Xcode/DerivedData/WebDriverAgentMac-elfheevbnxsaxiewwxjlzjrgolxe/Logs/Test/Test-WebDriverAgentRunner-2023.08.10_12-50-08-+0530.xcresult

2023-08-10 12:51:50.990 xcodebuild[1316:29143] [MT] IDETestOperationsObserverDebug: 90.538 elapsed -- Testing started completed. 2023-08-10 12:51:50.990 xcodebuild[1316:29143] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start 2023-08-10 12:51:50.990 xcodebuild[1316:29143] [MT] IDETestOperationsObserverDebug: 90.538 sec, +90.538 sec -- end

Test session results, code coverage, and logs: /Users/saurabhkoli/Library/Developer/Xcode/DerivedData/WebDriverAgentMac-elfheevbnxsaxiewwxjlzjrgolxe/Logs/Test/Test-WebDriverAgentRunner-2023.08.10_12-50-08-+0530.xcresult

TEST EXECUTE INTERRUPTED `

sksang commented 10 months ago

And if I run my original test script now, I get this result:

[Appium] Welcome to Appium v2.0.1 (REV 98f1be77f93a0d23fbc68629d0854522e9f0c1c3) [Appium] Attempting to load driver mac2... [debug] [Appium] Requiring driver at /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver [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.1.4:4723/ [Appium] Available drivers: [Appium] - mac2@1.6.3 (automationName 'Mac2') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. [debug] [HTTP] Request idempotency key: 2c03ddb0-68f8-4d4f-bfd6-6ef8d67c7501 [HTTP] --> POST /session [HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:platform":"Mac","appium:device_name":"Mac","platformName":"Mac","appium:automationName":"Mac2","appium:commandDelay":50,"appium:loopDelay":0,"appium:mouseMoveSpeed":60,"appium:diagnosticsDirectoryLocation":"~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation"}}} [debug] [AppiumDriver@ebde] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:platform":"Mac","appium:device_name":"Mac","platformName":"Mac","appium:automationName":"Mac2","appium:commandDelay":50,"appium:loopDelay":0,"appium:mouseMoveSpeed":60,"appium:diagnosticsDirectoryLocation":"~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation"}}] [debug] [AppiumDriver@ebde] Event 'newSessionRequested' logged at 1691652342484 (12:55:42 GMT+0530 (India 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/saurabhkoli/.appium/node_modules/appium-mac2-driver [debug] [Appium] Requiring driver at /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver [AppiumDriver@ebde] Appium v2.0.1 creating new Mac2Driver (v1.6.3) session [AppiumDriver@ebde] Checking BaseDriver versions for Appium and Mac2Driver [AppiumDriver@ebde] Appium's BaseDriver version is 9.3.16 [AppiumDriver@ebde] Mac2Driver's BaseDriver version is 9.3.16 [debug] [Mac2Driver@7947] Creating session with W3C capabilities: { [debug] [Mac2Driver@7947] "alwaysMatch": { [debug] [Mac2Driver@7947] "platformName": "Mac", [debug] [Mac2Driver@7947] "appium:platform": "Mac", [debug] [Mac2Driver@7947] "appium:device_name": "Mac", [debug] [Mac2Driver@7947] "appium:automationName": "Mac2", [debug] [Mac2Driver@7947] "appium:commandDelay": 50, [debug] [Mac2Driver@7947] "appium:loopDelay": 0, [debug] [Mac2Driver@7947] "appium:mouseMoveSpeed": 60, [debug] [Mac2Driver@7947] "appium:diagnosticsDirectoryLocation": "~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation" [debug] [Mac2Driver@7947] }, [debug] [Mac2Driver@7947] "firstMatch": [ [debug] [Mac2Driver@7947] {} [debug] [Mac2Driver@7947] ] [debug] [Mac2Driver@7947] } [Mac2Driver@7947] The following capabilities were provided, but are not recognized by Appium: [Mac2Driver@7947] platform [Mac2Driver@7947] device_name [Mac2Driver@7947] commandDelay [Mac2Driver@7947] loopDelay [Mac2Driver@7947] mouseMoveSpeed [Mac2Driver@7947] diagnosticsDirectoryLocation [Mac2Driver@7947 (3a834f1f)] Session created with session id: 3a834f1f-585c-4d07-8996-55fc581189de [debug] [WebDriverAgentMac] Using bootstrap root: /Users/saurabhkoli/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac [debug] [WebDriverAgentMac] Using xcodebuild binary at '/usr/bin/xcodebuild' [WebDriverAgentMac] There is no need to perform the project cleanup. A fresh install has been detected [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/saurabhkoli/.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 [debug] [WD Proxy] Got response with status 200: {"value":{"message":"WebDriverAgent is ready to accept commands","state":"success","os":{"version":"Version 13.3 (Build 22E252)"},"ready":true,"build":{"time":"Aug 10 2023 12:50:18"}},"sessionId":null} [WebDriverAgentMac] The host process is ready within 2121ms [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","platform":"Mac","device_name":"Mac","automationName":"Mac2","commandDelay":50,"loopDelay":0,"mouseMoveSpeed":60,"diagnosticsDirectoryLocation":"~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation"}}} [debug] [WD Proxy] Got response with status 200: {"value":{"sessionId":"D552E6E4-C119-490A-8F69-5ABF3E1F1A37","capabilities":{"CFBundleIdentifier":"com.apple.finder"}},"sessionId":"D552E6E4-C119-490A-8F69-5ABF3E1F1A37"} [WD Proxy] Determined the downstream protocol as 'W3C' [AppiumDriver@ebde] New Mac2Driver session created successfully, session 3a834f1f-585c-4d07-8996-55fc581189de added to master session list [debug] [AppiumDriver@ebde] Event 'newSessionStarted' logged at 1691652344649 (12:55:44 GMT+0530 (India Standard Time)) [debug] [Mac2Driver@7947 (3a834f1f)] Cached the protocol value 'W3C' for the new session 3a834f1f-585c-4d07-8996-55fc581189de [debug] [Mac2Driver@7947 (3a834f1f)] Responding to client with driver.createSession() result: {"capabilities":{"platformName":"Mac","platform":"Mac","device_name":"Mac","automationName":"Mac2","commandDelay":50,"loopDelay":0,"mouseMoveSpeed":60,"diagnosticsDirectoryLocation":"~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation"}} [HTTP] <-- POST /session 200 2168 ms - 304 [HTTP] [HTTP] --> POST /session/3a834f1f-585c-4d07-8996-55fc581189de/url [HTTP] {"url":"/System/Applications/Utilities/Activity Monitor.app"} [Mac2Driver@7947 (3a834f1f)] Driver proxy active, passing request on via HTTP proxy [debug] [WD Proxy] Matched '/session/3a834f1f-585c-4d07-8996-55fc581189de/url' to command name 'setUrl' [debug] [WD Proxy] Proxying [POST /session/3a834f1f-585c-4d07-8996-55fc581189de/url] to [POST http://127.0.0.1:10100/session/D552E6E4-C119-490A-8F69-5ABF3E1F1A37/url] with body: {"url":"/System/Applications/Utilities/Activity Monitor.app"} [WD Proxy] Got response with status 400: {"value":{"error":"invalid argument","message":"'/System/Applications/Utilities/Activity Monitor.app' should be a valid URL","traceback":""},"sessionId":"D552E6E4-C119-490A-8F69-5ABF3E1F1A37"} [debug] [W3C] Matched W3C error code 'invalid argument' to InvalidArgumentError [HTTP] <-- POST /session/3a834f1f-585c-4d07-8996-55fc581189de/url 400 13 ms - 729 [HTTP] [Mac2Driver@7947 (3a834f1f)] Shutting down because we waited 60 seconds for a command [AppiumDriver@ebde] Ending session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability' [AppiumDriver@ebde] Removing session '3a834f1f-585c-4d07-8996-55fc581189de' from our master session list [debug] [WD Proxy] Matched '/session/D552E6E4-C119-490A-8F69-5ABF3E1F1A37' to command name 'deleteSession' [debug] [WD Proxy] Proxying [DELETE /session/D552E6E4-C119-490A-8F69-5ABF3E1F1A37] to [DELETE http://127.0.0.1:10100/session/D552E6E4-C119-490A-8F69-5ABF3E1F1A37] with no body [debug] [WD Proxy] Got response with status 200: {"value":null,"sessionId":null}

sksang commented 10 months ago

Hi @KazuCocoa please let me know if there is any change needed in my original python script.

KazuCocoa commented 10 months ago

it is expected. driver.get("/System/Applications/Utilities/Activity Monitor.app") is open the given url, but the given one was not url. If you wan't to launch an app, https://github.com/appium/appium-mac2-driver#macos-launchapp may help. It needs to give bundle id.

sksang commented 10 months ago

Thanks a lot @KazuCocoa for addressing the doubts well within time !

Now I have few more doubts:

  1. I could not see the suggestion in comment https://github.com/appium/appium-mac2-driver/issues/215#issuecomment-1672670671 in the Requrements section. Please let me know if there is any additional section for the requirements elsewhere.
  2. Earlier I just downloaded the AppiumForMac > installed > gave Accessibility Permission and thats all. It worked. But do I need to build WebDriverAgentMac.xcodeproj always on a new machine ?
  3. Is there any way to stop the display of WaterMark "Automation Running" while script is being run ?
  4. And from the comment https://github.com/appium/appium-mac2-driver/issues/215#issuecomment-1672784478, the app is already launched with creation of driver then how can I find element on it. previously I used to call driver.get with appname and did not provide bundleID in capabilities and used to work. Is there any change now ?
KazuCocoa commented 10 months ago
  1. showServerLogs is capabilities to get more logs, not "requirements"
  2. Yes, currently so. the app needs to run XCTest session, so it is different from the old one. Probably we could find somehow to launch an app with XCTest session but I'm not sure yet.
  3. It is Apple's limitation
  4. This driver uses XCTest framework It needs the bundle id to launch an app, so currently this requires the bundle id. Potentially it can get the bundle id from plist.info from the .app as the future improvement (i guess..). At least this driver is similar to Appium XCUITest driver, but not the previous MacDriver.
sksang commented 10 months ago

Hi @KazuCocoa I am using driver.find_element(By.XPATH, x_path_sign_in) Where I have recorded xpath with AppiumForMac tool. as "/AXApplication[@AXTitle='Prime Video']/AXWindow[@AXTitle='Prime Video' and @AXIdentifier='SceneWindow' and @AXSubrole='AXStandardWindow']/AXGroup[@AXSubrole='iOSContentGroup']/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[1]/AXGroup[0]/AXGroup[0]/AXGroup[@AXIdentifier='AuthPortalWebView']/AXScrollArea[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXWebArea[0]/AXButton[0]"

But I am getting below error:

[Mac2Driver@0a6b (eb74b6ef)] Encountered internal error running command: NoSuchElementError: unable to find an element using 'xpath', value '/AXApplication[@AXTitle='Prime Video']/AXWindow[@AXTitle='Prime Video' and @AXIdentifier='SceneWindow' and @AXSubrole='AXStandardWindow']/AXGroup[@AXSubrole='iOSContentGroup']/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[1]/AXGroup[0]/AXGroup[0]/AXGroup[@AXIdentifier='AuthPortalWebView']/AXScrollArea[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXWebArea[0]/AXButton[0]'

Please let me know which method to use to click the element. The app is opened by the bundleID but elements are not accessible.

KazuCocoa commented 10 months ago

What's the page source? This driver is via XCTest framework, so elements what are available via XCTest framework are available

sksang commented 10 months ago

Hi @KazuCocoa This is the complete python code :

`import time from appium import webdriver from selenium.webdriver.common.by import By

desired_capabilities = { 'platform': 'Mac', 'device_name': 'Mac', 'platformName': 'Mac', 'automationName': 'Mac2', 'commandDelay': 50, 'loopDelay': 0, 'mouseMoveSpeed': 60, 'diagnosticsDirectoryLocation': '~/Documents/Appium_MacOS_Automation/MacOS_Apps_Automation', 'bundleId': 'com.amazon.aiv.AIVApp' }

driver = webdriver.Remote(command_executor="http://localhost:4723", desired_capabilities=desired_capabilities)

time.sleep(10)

x_path_sign_in = "/AXApplication[@AXTitle='Prime Video']/AXWindow[@AXTitle='Prime Video' and @AXIdentifier='SceneWindow' and @AXSubrole='AXStandardWindow']/AXGroup[@AXSubrole='iOSContentGroup']/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[1]/AXGroup[0]/AXGroup[0]/AXGroup[@AXIdentifier='AuthPortalWebView']/AXScrollArea[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXGroup[0]/AXWebArea[0]/AXButton[0]"

driver.find_element(By.XPATH, x_path_sign_in) time.sleep(5)`

sksang commented 10 months ago

This is for Prime Video App Test Automation.

sksang commented 10 months ago

@KazuCocoa Is there any sample code for Python client available ?

KazuCocoa commented 10 months ago

Afaik, https://github.com/appium/appium-mac2-driver#examples is.

What's the page source?

This means the result of driver.page_source. Usually, elements listed in the page source are available. What is the result of it?

sksang commented 10 months ago

@KazuCocoa This is the page source:

<?xml version="1.0" encoding="UTF-8"?>
<XCUIElementTypeApplication elementType="2" identifier="" label="" title="Prime Video" enabled="false" selected="false" x="0" y="0" width="0" height="0">
  <XCUIElementTypeWindow elementType="4" identifier="SceneWindow" label="" title="Prime Video" enabled="false" selected="false" x="150" y="36" width="1024" height="768">
    <XCUIElementTypeGroup elementType="3" identifier="" label="" title="" enabled="false" selected="false" x="150" y="36" width="1024" height="768">
      <XCUIElementTypeWindow elementType="4" identifier="" label="" title="" enabled="true" selected="false" x="150" y="36" width="1025" height="769">
        <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="36" width="1025" height="769">
          <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="36" width="1025" height="769">
            <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="36" width="1025" height="769">
              <XCUIElementTypeNavigationBar elementType="21" identifier="Prime Video" label="" title="" enabled="true" selected="false" x="150" y="63" width="1025" height="40">
                <XCUIElementTypeImage elementType="43" identifier="" label="Prime Video" title="" enabled="true" selected="false" x="615" y="67" width="95" height="31"/>
                <XCUIElementTypeButton elementType="9" identifier="" label="Refresh" title="" enabled="true" selected="false" x="1132" y="66" width="33" height="34"/>
              </XCUIElementTypeNavigationBar>
              <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="36" width="1025" height="769">
                <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="36" width="1025" height="769">
                  <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                    <XCUIElementTypeWebView elementType="58" identifier="AuthPortalWebView" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                      <XCUIElementTypeWebView elementType="58" identifier="" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                        <XCUIElementTypeWebView elementType="58" identifier="" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                          <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                            <XCUIElementTypeGroup elementType="3" identifier="" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                              <XCUIElementTypeGroup elementType="3" identifier="" label="" title="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                                <XCUIElementTypeScrollView elementType="46" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                                  <XCUIElementTypeWebView elementType="58" identifier="" value="" label="Amazon Sign-In" title="" placeholderValue="" enabled="true" selected="false" x="150" y="102" width="1025" height="703">
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
                                    <XCUIElementTypeOther elementType="1" identifier="" value="1" label="Sign in" title="" placeholderValue="" enabled="true" selected="false" x="508" y="118" width="309" height="39">
                                      <XCUIElementTypeStaticText elementType="48" identifier="" value="Sign in" label="Sign in" title="" placeholderValue="" enabled="true" selected="false" x="508" y="119" width="91" height="32"/>
                                    </XCUIElementTypeOther>
                                    <XCUIElementTypeGroup elementType="3" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="508" y="159" width="309" height="18">
                                      <XCUIElementTypeLink elementType="42" identifier="" value="" label="Forgot password?" title="" placeholderValue="" enabled="true" selected="false" x="710" y="159" width="107" height="17">
                                        <XCUIElementTypeLink elementType="42" identifier="" value="Forgot password?" label="Forgot password?" title="" placeholderValue="" enabled="true" selected="false" x="710" y="159" width="107" height="17"/>
                                      </XCUIElementTypeLink>
                                    </XCUIElementTypeGroup>
                                    <XCUIElementTypeGroup elementType="3" identifier="" value="" label="Email or phone number" title="" placeholderValue="" enabled="true" selected="false" x="508" y="186" width="4" height="4">
                                      <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="Email or phone number" title="" placeholderValue="" enabled="true" selected="false" x="511" y="186" width="45" height="61"/>
                                    </XCUIElementTypeGroup>
                                    <XCUIElementTypeTextField elementType="49" identifier="" value="Email or phone number" label="" title="" placeholderValue="Email or phone number" enabled="true" selected="false" x="508" y="188" width="308" height="43"/>
                                    <XCUIElementTypeSecureTextField elementType="50" identifier="" value="Amazon password" label="Amazon password" title="" placeholderValue="Amazon password" enabled="true" selected="false" x="508" y="232" width="308" height="42"/>
                                    <XCUIElementTypeGroup elementType="3" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="511" y="292" width="301" height="19">
                                      <XCUIElementTypeSwitch elementType="40" identifier="" value="0" label="" title="" placeholderValue="" enabled="true" selected="false" x="511" y="292" width="301" height="19"/>
                                      <XCUIElementTypeStaticText elementType="48" identifier="" value="Show password" label="" title="" placeholderValue="" enabled="true" selected="false" x="538" y="294" width="95" height="17"/>
                                    </XCUIElementTypeGroup>
                                    <XCUIElementTypeButton elementType="9" identifier="" value="" label="Sign in" title="" placeholderValue="" enabled="true" selected="false" x="508" y="338" width="308" height="43"/>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="By signing in, you agree to the " label="By signing in, you agree to the" title="" placeholderValue="" enabled="true" selected="false" x="508" y="394" width="159" height="16"/>
                                    <XCUIElementTypeLink elementType="42" identifier="" value="" label="Prime Video Terms of Use" title="" placeholderValue="" enabled="true" selected="false" x="665" y="394" width="136" height="16">
                                      <XCUIElementTypeLink elementType="42" identifier="" value="" label="Prime Video Terms of Use" title="" placeholderValue="" enabled="true" selected="false" x="665" y="394" width="136" height="16"/>
                                    </XCUIElementTypeLink>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="which can be found on the Amazon website." label="and license agreements which can be found on the Amazon website." title="" placeholderValue="" enabled="true" selected="false" x="508" y="410" width="307" height="32"/>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="150" y="496" width="1025" height="17"/>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="© 1996-2023, Amazon.com, Inc. or its affiliates" label="" title="" placeholderValue="" enabled="true" selected="false" x="541" y="520" width="242" height="15"/>
                                    <XCUIElementTypeScrollView elementType="46" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="-7549" y="-7597" width="2" height="2">
                                      <XCUIElementTypeWebView elementType="58" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="-7549" y="-7597" width="2" height="7"/>
                                    </XCUIElementTypeScrollView>
                                    <XCUIElementTypeStaticText elementType="48" identifier="" value="" label="" title="" placeholderValue="" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
                                  </XCUIElementTypeWebView>
                                </XCUIElementTypeScrollView>
                              </XCUIElementTypeGroup>
                            </XCUIElementTypeGroup>
                          </XCUIElementTypeOther>
                        </XCUIElementTypeWebView>
                        <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="1162" y="102" width="13" height="703"/>
                        <XCUIElementTypeOther elementType="1" identifier="" label="" title="" enabled="true" selected="false" x="150" y="792" width="1025" height="13"/>
                      </XCUIElementTypeWebView>
                    </XCUIElementTypeWebView>
                  </XCUIElementTypeOther>
                </XCUIElementTypeOther>
              </XCUIElementTypeOther>
            </XCUIElementTypeOther>
          </XCUIElementTypeOther>
        </XCUIElementTypeOther>
      </XCUIElementTypeWindow>
    </XCUIElementTypeGroup>
    <XCUIElementTypeButton elementType="9" identifier="_XCUI:CloseWindow" label="" title="" enabled="true" selected="false" x="157" y="42" width="14" height="16"/>
    <XCUIElementTypeButton elementType="9" identifier="_XCUI:FullScreenWindow" label="" title="" enabled="false" selected="false" x="197" y="42" width="14" height="16"/>
    <XCUIElementTypeButton elementType="9" identifier="_XCUI:MinimizeWindow" label="" title="" enabled="true" selected="false" x="177" y="42" width="14" height="16"/>
  </XCUIElementTypeWindow>
  <XCUIElementTypeMenuBar elementType="55" identifier="" label="" title="" enabled="true" selected="false" x="0" y="0" width="1440" height="24">
    <XCUIElementTypeMenuBarItem elementType="56" identifier="" label="" title="Apple" enabled="true" selected="false" x="10" y="0" width="33" height="24">
      <XCUIElementTypeMenu elementType="53" identifier="" label="" title="" enabled="true" selected="false" x="10" y="24" width="256" height="275">
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="About This Mac" enabled="true" selected="false" x="0" y="0" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="System Information…" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="22" width="256" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="System Settings…" enabled="true" selected="false" x="0" y="33" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="App Store…, 2 updates" enabled="true" selected="false" x="0" y="55" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="77" width="256" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Recent Items" enabled="true" selected="false" x="0" y="88" width="256" height="22">
          <XCUIElementTypeMenu elementType="53" identifier="" label="" title="" enabled="true" selected="false" x="2388" y="-2352" width="287" height="561">
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Applications" enabled="false" selected="false" x="0" y="0" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="AppiumForMac" enabled="true" selected="false" x="0" y="22" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “AppiumForMac” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="FaceTime" enabled="true" selected="false" x="0" y="44" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “FaceTime” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Google Chrome" enabled="true" selected="false" x="0" y="66" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Google Chrome” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Notes" enabled="true" selected="false" x="0" y="88" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Notes” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Pages" enabled="true" selected="false" x="0" y="110" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Pages” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Prime Video" enabled="true" selected="false" x="0" y="132" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Prime Video” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="PyCharm CE" enabled="true" selected="false" x="0" y="154" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “PyCharm CE” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Terminal" enabled="true" selected="false" x="0" y="176" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Terminal” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="TextEdit" enabled="true" selected="false" x="0" y="198" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “TextEdit” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Xcode" enabled="true" selected="false" x="0" y="220" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Xcode” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="242" width="287" height="11"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Documents" enabled="false" selected="false" x="0" y="253" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="[Appium] Welcome to Appium v2.0.ini" enabled="true" selected="false" x="0" y="275" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “[Appium] Welcome to Appium v2.0.ini” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="HelloWorld.py" enabled="true" selected="false" x="0" y="297" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “HelloWorld.py” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="IMG_0534.jpg" enabled="true" selected="false" x="0" y="319" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “IMG_0534.jpg” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Info.plist" enabled="true" selected="false" x="0" y="341" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Info.plist” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Info.plist" enabled="true" selected="false" x="0" y="363" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Info.plist” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="NICE" enabled="true" selected="false" x="0" y="385" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “NICE” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Saurabh_Koli_Atlas_Copco" enabled="true" selected="false" x="0" y="407" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Saurabh_Koli_Atlas_Copco” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Screenshot 2023-08-07 at 9.46.20 PM" enabled="true" selected="false" x="0" y="429" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Screenshot 2023-08-07 at 9.46.20 PM” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Screenshot 2023-08-07 at 9.48.45 PM" enabled="true" selected="false" x="0" y="451" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Screenshot 2023-08-07 at 9.48.45 PM” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Screenshot 2023-08-07 at 9.49.39 PM" enabled="true" selected="false" x="0" y="473" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Show “Screenshot 2023-08-07 at 9.49.39 PM” in Finder" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="495" width="287" height="11"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Servers" enabled="false" selected="false" x="0" y="506" width="287" height="22"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="528" width="287" height="11"/>
            <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Clear Menu" enabled="true" selected="false" x="0" y="539" width="287" height="22"/>
          </XCUIElementTypeMenu>
        </XCUIElementTypeMenuItem>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="110" width="256" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Force Quit…" enabled="true" selected="false" x="0" y="121" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Force Quit Prime Video" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="143" width="256" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Sleep" enabled="true" selected="false" x="0" y="154" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Restart…" enabled="true" selected="false" x="0" y="176" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Restart" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Shut Down…" enabled="true" selected="false" x="0" y="198" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Shut Down" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="220" width="256" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Lock Screen" enabled="true" selected="false" x="0" y="231" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Log Out Saurabh Koli…" enabled="true" selected="false" x="0" y="253" width="256" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="Log Out Saurabh Koli" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
      </XCUIElementTypeMenu>
    </XCUIElementTypeMenuBarItem>
    <XCUIElementTypeMenuBarItem elementType="56" identifier="com.apple.menu.application" label="" title="Prime Video" enabled="true" selected="false" x="43" y="0" width="99" height="24">
      <XCUIElementTypeMenu elementType="53" identifier="" label="" title="" enabled="true" selected="false" x="43" y="24" width="200" height="132">
        <XCUIElementTypeMenuItem elementType="54" identifier="orderFrontStandardAboutPanel:" label="" title="About Prime Video" enabled="true" selected="false" x="0" y="0" width="200" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="22" width="200" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="hide:" label="" title="Hide Prime Video" enabled="true" selected="false" x="0" y="33" width="200" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="hideOtherApplications:" label="" title="Hide Others" enabled="true" selected="false" x="0" y="55" width="200" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="unhideAllApplications:" label="" title="Show All" enabled="false" selected="false" x="0" y="77" width="200" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="" label="" title="" enabled="false" selected="false" x="0" y="99" width="200" height="11"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="terminate:" label="" title="Quit Prime Video" enabled="true" selected="false" x="0" y="110" width="200" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="NSAlternateQuitMenuItem" label="" title="Quit and Keep Windows" enabled="true" selected="false" x="0" y="0" width="0" height="0"/>
      </XCUIElementTypeMenu>
    </XCUIElementTypeMenuBarItem>
    <XCUIElementTypeMenuBarItem elementType="56" identifier="com.apple.menu.view" label="" title="View" enabled="true" selected="false" x="142" y="0" width="50" height="24">
      <XCUIElementTypeMenu elementType="53" identifier="" label="" title="" enabled="true" selected="false" x="142" y="24" width="187" height="44">
        <XCUIElementTypeMenuItem elementType="54" identifier="toggleSidebar:" label="" title="Show Sidebar" enabled="false" selected="false" x="0" y="0" width="187" height="22"/>
        <XCUIElementTypeMenuItem elementType="54" identifier="toggleFullScreen:" label="" title="Enter Full Screen" enabled="true" selected="false" x="0" y="22" width="187" height="22"/>
      </XCUIElementTypeMenu>
    </XCUIElementTypeMenuBarItem>
  </XCUIElementTypeMenuBar>
  <XCUIElementTypeTouchBar elementType="81" identifier="" label="" title="" enabled="false" selected="false" x="80" y="30" width="685" height="30"/>
</XCUIElementTypeApplication>
sksang commented 10 months ago

Hi @KazuCocoa surprisingly I could not draw any correlation between the selector used in case of textEdit example as well.(Though the textEdit is working on my side also :-) ) Here is the xpath I recorded for the Text element in testEdit:

"/AXApplication[@AXTitle='TextEdit']/AXWindow[@AXTitle='Untitled' and @AXIdentifier='_NS:34' and @AXSubrole='AXStandardWindow']/AXScrollArea[@AXIdentifier='_NS:8']/AXTextArea[@AXIdentifier='First Text View']"

And here is how the text element is actually accessed in the script in example shared by you.

edit_field = drv.find_element(by=AppiumBy.CLASS_NAME, value='XCUIElementTypeTextView')

Now I am confused as to how to configure the CLASS_NAME from recorded xpath using AppiumForMac.

Please share your inputs on this.

KazuCocoa commented 10 months ago

it is how https://developer.apple.com/documentation/xctest by Apple recognizes each element, this driver refers to.

Perhaps searching XCUITest driver is easier to find hints. Both work via XCTest framework. https://github.com/appium/appium-xcuitest-driver/blob/b4f5d9ca28106c4cf2bbb97bb9a0f764abfd8b30/test/functional/basic/find-e2e-specs.js#L125

sksang commented 10 months ago

@KazuCocoa I need to know how can I configure CLASS_NAME from xpath recorded using AppiumForMac ? xpath = "/AXApplication[@AXTitle='TextEdit']/AXWindow[@AXTitle='Untitled' and @AXIdentifier='_NS:34' and @AXSubrole='AXStandardWindow']/AXScrollArea[@AXIdentifier='_NS:8']/AXTextArea[@AXIdentifier='First Text View']"

In case if only CLASS_NAME is supported as of now.

sksang commented 10 months ago

Hi @KazuCocoa , if xpath is listed in https://github.com/appium/appium-mac2-driver#element-location for element identification (which previously worked BTW), why is it not detecting and clicking anymore ?

KazuCocoa commented 10 months ago

AppiumForMac and this driver have no compatibility especially XPath as via XCTest framework or not. So the class name is basically should follow XCTest framework, XCUI prefix ones.

which previously worked BTW

What do you mean? Find an element -> do some actions against the element. Then, the action raised an exception, like this?

sksang commented 10 months ago

@KazuCocoa It worked previously by that I mean it identified elements and clicked it successfully. Anyway please let me know How do I get the class name for the element. As from above xpath recorded from AppoumForMac is not giving any classname in the same. I tried with accessibility inspector, that also does not work.

KazuCocoa commented 10 months ago

If the element information is updated by XCTest framework, such a case could happen.

class name in this driver is XCUI prefix ones by XCTest framework. I'm not sure Apple provides 1:1 map for the AX prefix ones, but you may need to find elements from the page source https://github.com/appium/appium-mac2-driver/issues/215#issuecomment-1675222296 and convert one by one. (if you'd like to eonvert elements used in the AppoumForMac to this XCTest framework based driver.

https://discuss.appium.io/ may help to ask questions.

sksang commented 10 months ago

So in short the AppiumForMac recorded xpath is not working even when the xpath support is provided by the Appium for mac. There can be two cases:

  1. The AppiumForMac is producing incorrect xpath(inaccessible xpath).
  2. The xpath recorded by AppiumForMac is correct and the driver is failing to detect the element. Shouldn't be this an issue @KazuCocoa ?
KazuCocoa commented 10 months ago

Correct, they are different drivers (different automation names). This driver depends on XCTest framework, but the old AppiumForMac was not. Sorry, am confusing a bit about asking AppiumForMac stuff here continuously, but AppiumForMac is not related to this driver, and some comments above addressed this driver needs XCUI prefix ones for class names as your page source result in https://github.com/appium/appium-mac2-driver/issues/215#issuecomment-1675222296 . So AppiumForMac stuff does not this driver as-is is expected behavior.