Problems finding Elements using appium2 & Mac2Driver with c# to automate website tests on a remote Mac

Hello,
I’m trying to run my Tests that already work well on windows (with selenium) and on Android (with appium) on a remote Mac. I want to run them on ios as well, but first I want them to be able to run on the Mac. I’m starting the appium server manually from the Mac and can then start my tests on the Windows Machine, which communicates with the Mac so Safari is started and calls the desired URL. But on the Webpage, none of the Elements can be found. I can see them on the screen, but I always get a ElementNotFoundException.

The c# code:

public static WebDriver GetRemoteSafariDriver(string IPAdress)
    {
        AppiumOptions capabilities = new AppiumOptions();
        capabilities.AutomationName = "mac2";
        capabilities.DeviceName = "tp-mac-01";
        capabilities.PlatformName = "Mac";
        capabilities.PlatformVersion = "13.3.1";
        capabilities.AddAdditionalAppiumOption("appium:bundleId", "com.apple.Safari");
        capabilities.AddAdditionalAppiumOption("showServerLogs", true);
        capabilities.AddAdditionalAppiumOption("appium:includeSafariInWebviews", "true");
        

        AppiumDriver driver = new MacDriver(new Uri("http://"+IPAdress+":4723/"), capabilities, TimeSpan.FromMilliseconds(60000));
        driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(60000);
        return driver;
    }

The Appium log:

[Appium] Welcome to Appium v2.0.0-beta.66 (REV 763c41f006ab9b44261e313b0aaa24a047431b06)

[Appium] Attempting to load driver xcuitest…
[debug] [Appium] Requiring driver at /Users/…/.appium/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver mac2…
[debug] [Appium] Requiring driver at /Users/…/.appium/node_modules/appium-mac2-driver
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘XCUITest’)
[Appium] - [email protected] (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: 352a6136-eb7d-477a-88a2-3d12a48f5849
[HTTP] --> POST /session
[HTTP] {“capabilities”:{“firstMatch”:[{“platformName”:“Mac”,“appium:automationName”:“mac2”,“appium:deviceName”:“tp-mac-01”,“appium:platformVersion”:“13.3.1”,“appium:bundleId”:“com.apple.Safari”,“appium:showServerLogs”:true,“appium:includeSafariInWebviews”:“true”}]}}
[debug] [AppiumDriver@e4b0] Calling AppiumDriver.createSession() with args: [null,null,{“firstMatch”:[{“platformName”:“Mac”,“appium:automationName”:“mac2”,“appium:deviceName”:“tp-mac-01”,“appium:platformVersion”:“13.3.1”,“appium:bundleId”:“com.apple.Safari”,“appium:showServerLogs”:true,“appium:includeSafariInWebviews”:“true”}]}]
[debug] [AppiumDriver@e4b0] Event ‘newSessionRequested’ logged at 1683192863312 (11:34:23 GMT+0200 (Central European Summer 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/…/.appium/node_modules/appium-mac2-driver
[debug] [Appium] Requiring driver at /Users/…/.appium/node_modules/appium-mac2-driver
[AppiumDriver@e4b0] Appium v2.0.0-beta.66 creating new Mac2Driver (v1.5.3) session
[AppiumDriver@e4b0] Checking BaseDriver versions for Appium and Mac2Driver
[AppiumDriver@e4b0] Appium’s BaseDriver version is 9.3.7
[AppiumDriver@e4b0] Mac2Driver’s BaseDriver version is 9.3.7
[debug] [Mac2Driver@be94] Creating session with W3C capabilities: {
[debug] [Mac2Driver@be94] “alwaysMatch”: {
[debug] [Mac2Driver@be94] “platformName”: “Mac”,
[debug] [Mac2Driver@be94] “appium:automationName”: “mac2”,
[debug] [Mac2Driver@be94] “appium:deviceName”: “tp-mac-01”,
[debug] [Mac2Driver@be94] “appium:platformVersion”: “13.3.1”,
[debug] [Mac2Driver@be94] “appium:bundleId”: “com.apple.Safari”,
[debug] [Mac2Driver@be94] “appium:showServerLogs”: true,
[debug] [Mac2Driver@be94] “appium:includeSafariInWebviews”: “true”
[debug] [Mac2Driver@be94] },
[debug] [Mac2Driver@be94] “firstMatch”: [
[debug] [Mac2Driver@be94] {}
[debug] [Mac2Driver@be94] ]
[debug] [Mac2Driver@be94] }
[Mac2Driver@be94] The following capabilities were provided, but are not recognized by Appium:
[Mac2Driver@be94] includeSafariInWebviews
[Mac2Driver@be94 (42b68278)] Session created with session id: 42b68278-94c3-4f2e-94a2-32fd30c70cc4
[debug] [WebDriverAgentMac] Using bootstrap root: /Users/…/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac
[debug] [WebDriverAgentMac] Using xcodebuild binary at ‘/usr/bin/xcodebuild’
[WebDriverAgentMac] WebDriverAgent sources are up to date (1682497641066 >= 1682497641066)
[debug] [WebDriverAgentMac] Using 127.0.0.1 as server host
[debug] [WebDriverAgentMac] Using port 10100
[WebDriverAgentMac] Starting Mac2Driver host process: xcodebuild build-for-testing test-without-building -project /Users/…/.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] [WebDriverAgentMac] [xcodebuild] 2023-05-04 11:34:23.987 xcodebuild[1503:56845] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
[debug] [WebDriverAgentMac] [xcodebuild] Command line invocation:
[debug] [WebDriverAgentMac] [xcodebuild] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild build-for-testing test-without-building -project /Users/…/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj -scheme WebDriverAgentRunner COMPILER_INDEX_STORE_ENABLE=NO
[debug] [WebDriverAgentMac]
[debug] [WebDriverAgentMac] User defaults from command line:
[debug] [WebDriverAgentMac] IDEPackageSupportUseBuiltinSCM = YES
[debug] [WebDriverAgentMac]
[debug] [WebDriverAgentMac] Build settings from command line:
[debug] [WebDriverAgentMac] COMPILER_INDEX_STORE_ENABLE = NO
[debug] [WebDriverAgentMac] [xcodebuild] — xcodebuild: WARNING: Using the first of multiple matching destinations:
[debug] [WebDriverAgentMac] { platform:macOS, arch:arm64, id:00008103-001E64810C53001E }
[debug] [WebDriverAgentMac] { platform:macOS, arch:x86_64, id:00008103-001E64810C53001E }
[debug] [WebDriverAgentMac] { platform:macOS, name:Any Mac }
[debug] [WebDriverAgentMac] [xcodebuild] Prepare packages
[debug] [WebDriverAgentMac] [xcodebuild] Computing target dependency graph and provisioning inputs
[debug] [WebDriverAgentMac] [xcodebuild] Create build description
[debug] [WebDriverAgentMac] [xcodebuild] note: Building targets in dependency order
[debug] [WebDriverAgentMac] [xcodebuild] ClangStatCache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk /Users/…/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx13.3-22E245-.sdkstatcache
[debug] [WebDriverAgentMac] cd /Users/…/.appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentMac.xcodeproj
[debug] [WebDriverAgentMac] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -o /Users/…/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx13.3-22E245-.sdkstatcache
[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] [WebDriverAgentMac] [xcodebuild] ** TEST BUILD SUCCEEDED **
[debug] [WebDriverAgentMac] [xcodebuild] — xcodebuild: WARNING: Using the first of multiple matching destinations:
[debug] [WebDriverAgentMac] { platform:macOS, arch:arm64, id:00008103-001E64810C53001E }
[debug] [WebDriverAgentMac] { platform:macOS, arch:x86_64, id:00008103-001E64810C53001E }
[debug] [WebDriverAgentMac] { platform:macOS, name:Any Mac }
[debug] [WebDriverAgentMac] [xcodebuild] 2023-05-04 11:34:24.629192+0200 WebDriverAgentRunner-Runner[1508:56980] Running tests…
[debug] [WebDriverAgentMac] [xcodebuild] Test Suite ‘All tests’ started at 2023-05-04 11:34:24.654
[debug] [WebDriverAgentMac] [xcodebuild] Test Suite ‘WebDriverAgentRunner.xctest’ started at 2023-05-04 11:34:24.654
[debug] [WebDriverAgentMac] Test Suite ‘UITestingUITests’ started at 2023-05-04 11:34:24.654
[debug] [WebDriverAgentMac] t = nans Suite Set Up
[debug] [WebDriverAgentMac] [xcodebuild] Test Case ‘-[UITestingUITests testRunner]’ started.
[debug] [WebDriverAgentMac] [xcodebuild] t = 0.00s Start Test at 2023-05-04 11:34:24.655
[debug] [WebDriverAgentMac] [xcodebuild] t = 0.02s Set Up
[debug] [WebDriverAgentMac] [xcodebuild] 2023-05-04 11:34:24.670695+0200 WebDriverAgentRunner-Runner[1508:56980] Built at Apr 27 2023 12:21:55
[debug] [WebDriverAgentMac] [xcodebuild] 2023-05-04 11:34:24.675886+0200 WebDriverAgentRunner-Runner[1508:56980] ServerURLHere->http:// localhost:10100<-ServerURLHere
[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.1 (a) (Build 22E772610a)”},“ready”:true,“build”:{“time”:“Apr 27 2023 12:21:55”}},“sessionId”:null}
[WebDriverAgentMac] The host process is ready within 2098ms
[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”,“deviceName”:“tp-mac-01”,“platformVersion”:“13.3.1”,“bundleId”:“com.apple.Safari”,“showServerLogs”:true,“includeSafariInWebviews”:“true”}}}
[debug] [WebDriverAgentMac] [xcodebuild] t = 0.79s Open com.apple.Safari
[debug] [WebDriverAgentMac] [xcodebuild] t = 0.79s Launch com.apple.Safari
[debug] [WebDriverAgentMac] [xcodebuild] t = 0.79s Terminate com.apple.Safari:517
[debug] [WebDriverAgentMac] [xcodebuild] t = 1.97s Wait for accessibility to load
[debug] [WebDriverAgentMac] [xcodebuild] t = 2.37s Setting up automation session
[debug] [WebDriverAgentMac] [xcodebuild] t = 2.40s Wait for com.apple.Safari to idle
[debug] [WD Proxy] Got response with status 200: {“value”:{“sessionId”:“E0174915-1FF5-4261-8FDF-189A53A5D600”,“capabilities”:{“CFBundleIdentifier”:“com.apple.Safari”}},“sessionId”:“E0174915-1FF5-4261-8FDF-189A53A5D600”}
[WD Proxy] Determined the downstream protocol as ‘W3C’
[AppiumDriver@e4b0] New Mac2Driver session created successfully, session 42b68278-94c3-4f2e-94a2-32fd30c70cc4 added to master session list
[debug] [AppiumDriver@e4b0] Event ‘newSessionStarted’ logged at 1683192867070 (11:34:27 GMT+0200 (Central European Summer Time))
[debug] [Mac2Driver@be94 (42b68278)] Cached the protocol value ‘W3C’ for the new session 42b68278-94c3-4f2e-94a2-32fd30c70cc4
[debug] [Mac2Driver@be94 (42b68278)] Responding to client with driver.createSession() result: {“capabilities”:{“platformName”:“Mac”,“automationName”:“mac2”,“deviceName”:“tp-mac-01”,“platformVersion”:“13.3.1”,“bundleId”:“com.apple.Safari”,“showServerLogs”:true,“includeSafariInWebviews”:“true”}}
[HTTP] <-- POST /session 200 3768 ms - 261
[HTTP]
[debug] [HTTP] Request idempotency key: 08f683ff-ee0e-4006-8be4-461db8afbf35
[HTTP] --> POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/timeouts
[HTTP] {“implicit”:60000}
[debug] [Mac2Driver@be94 (42b68278)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,60000,“42b68278-94c3-4f2e-94a2-32fd30c70cc4”]
[debug] [Mac2Driver@be94 (42b68278)] W3C timeout argument: {“implicit”:60000}}
[debug] [Mac2Driver@be94 (42b68278)] Set implicit wait to 60000ms
[debug] [Mac2Driver@be94 (42b68278)] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/timeouts 200 3 ms - 14
[HTTP]
[debug] [HTTP] Request idempotency key: a02a944e-9313-419a-b94c-fe1cd2d5f2bc
[HTTP] --> POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/url
[HTTP] {“url”:“you don’t need to know the url”}
[Mac2Driver@be94 (42b68278)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched ‘/session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/url’ to command name ‘setUrl’
[debug] [WD Proxy] Proxying [POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/url] to [POST http:// 127.0.0.1:10100/session/E0174915-1FF5-4261-8FDF-189A53A5D600/url] with body: {“url”:“you don’t need the url”}
[debug] [WD Proxy] Got response with status 200: {“value”:null,“sessionId”:“E0174915-1FF5-4261-8FDF-189A53A5D600”}
[WD Proxy] Replacing sessionId E0174915-1FF5-4261-8FDF-189A53A5D600 with 42b68278-94c3-4f2e-94a2-32fd30c70cc4
[HTTP] <-- POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/url 200 31 ms - 65
[HTTP]
[debug] [HTTP] Request idempotency key: fa165917-17fe-4fb9-96d4-dfc79d356f26
[HTTP] --> POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/window/maximize
[HTTP] {}
[Mac2Driver@be94 (42b68278)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched ‘/session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/window/maximize’ to command name ‘maximizeWindow’
[debug] [WD Proxy] Proxying [POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/window/maximize] to [POST http:// 127.0.0.1:10100/session/E0174915-1FF5-4261-8FDF-189A53A5D600/window/maximize] with body: {}
[debug] [WebDriverAgentMac] [xcodebuild] t = 2.61s Find the Application ‘com.apple.Safari’
[debug] [WebDriverAgentMac] [xcodebuild] t = 2.87s Find the Application ‘com.apple.Safari’
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.00s Get all elements bound by accessibility element for: Elements matching predicate ‘"_XCUI:FullScreenWindow" IN identifiers’
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.20s Find the “_XCUI:FullScreenWindow” Button
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.40s Click “_XCUI:FullScreenWindow” Button
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.40s Wait for com.apple.Safari to idle
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.40s Find the “_XCUI:FullScreenWindow” Button
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.63s Check for interrupting elements affecting “_XCUI:FullScreenWindow” Button
[debug] [WebDriverAgentMac] [xcodebuild] t = 3.64s Synthesize event
[debug] [WebDriverAgentMac] [xcodebuild] t = 4.03s Wait for com.apple.Safari to idle
[debug] [WD Proxy] Got response with status 200: {“value”:null,“sessionId”:“E0174915-1FF5-4261-8FDF-189A53A5D600”}
[WD Proxy] Replacing sessionId E0174915-1FF5-4261-8FDF-189A53A5D600 with 42b68278-94c3-4f2e-94a2-32fd30c70cc4
[HTTP] <-- POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/window/maximize 200 1949 ms - 65
[HTTP]
[debug] [HTTP] Request idempotency key: 28634994-e509-424c-9ca9-331fd1942784
[HTTP] --> POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/timeouts
[HTTP] {“implicit”:6000}
[debug] [Mac2Driver@be94 (42b68278)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,6000,“42b68278-94c3-4f2e-94a2-32fd30c70cc4”]
[debug] [Mac2Driver@be94 (42b68278)] W3C timeout argument: {“implicit”:6000}}
[debug] [Mac2Driver@be94 (42b68278)] Set implicit wait to 6000ms
[debug] [Mac2Driver@be94 (42b68278)] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/timeouts 200 3 ms - 14
[HTTP]
[debug] [HTTP] Request idempotency key: 15779728-e359-49d5-bc9f-bf23ba84ff0b
[HTTP] --> POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/element
[HTTP] {“using”:“xpath”,“value”:"//[@data-automation-id=‘inputLoginPassword’]"}
[debug] [Mac2Driver@be94 (42b68278)] Calling AppiumDriver.findElement() with args: [“xpath”,"//
[@data-automation-id=‘inputLoginPassword’]",“42b68278-94c3-4f2e-94a2-32fd30c70cc4”]
[debug] [Mac2Driver@be94 (42b68278)] Valid locator strategies for this request: id, name, accessibility id, xpath, class name, -ios predicate string, predicate string, -ios class chain, class chain
[debug] [WD Proxy] Matched ‘/element’ to command name ‘findElement’
[debug] [WD Proxy] Proxying [POST /element] to [POST http:// 127.0.0.1:10100/session/E0174915-1FF5-4261-8FDF-189A53A5D600/element] with body: {“using”:“xpath”,“value”:"//[@data-automation-id=‘inputLoginPassword’]"}
[debug] [WebDriverAgentMac] [xcodebuild] t = 4.59s Find the Application ‘com.apple.Safari’
[WD Proxy] Got response with status 404: {“value”:{“error”:“no such element”,“message”:"unable to find an element using ‘xpath’, value '//
[@data-automation-id=‘inputLoginPassword’]’",“traceback”:"(\n\t0 WebDriverAgentLib 0x0000000105a212fc FBNoSuchElementErrorResponseForRequest + 252\n\t1 WebDriverAgentLib 0x0000000105a210a0 +[FBFindElementCommands handleFindElement:] + 380\n\t2 WebDriverAgentLib 0x0000000105a61f18 -[FBRoute_TargetAction mountRequest:intoResponse:] + 168\n\t3 WebDriverAgentLib 0x0000000105a5c180 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 652\n\t4 WebDriverAgentLib 0x0000000105a563f4 -[RoutingHTTPServer handleRoute:withRequest:response:] + 168\n\t5 WebDriverAgentLib 0x0000000105a56e3c __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t6 libdispatch.dylib 0x00000001a5890400 _dispatch_client_callout + 20\n\t7 libdispatch.dylib …
[debug] [W3C] Matched W3C error code ‘no such element’ to NoSuchElementError
[debug] [Mac2Driver@be94 (42b68278)] Encountered internal error running command: NoSuchElementError: unable to find an element using ‘xpath’, value '//[@data-automation-id=‘inputLoginPassword’]’
[debug] [Mac2Driver@be94 (42b68278)] at errorFromW3CJsonCode (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1034:25)
[debug] [Mac2Driver@be94 (42b68278)] at ProxyRequestError.getActualError (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:909:14)
[debug] [Mac2Driver@be94 (42b68278)] at WDAMacProxy.command (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:340:19)
[debug] [Mac2Driver@be94 (42b68278)] at processTicksAndRejections (node:internal/process/task_queues:95:5)
[debug] [Mac2Driver@be94 (42b68278)] at Mac2Driver.findElOrEls (/Users/…/.appium/node_modules/appium-mac2-driver/lib/commands/find.js:17:10)
[debug] [Mac2Driver@be94 (42b68278)] at Mac2Driver.findElOrElsWithProcessing (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:66:14)
[debug] [Mac2Driver@be94 (42b68278)] at Mac2Driver.findElement (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:13:12)
[HTTP] <-- POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/element 404 432 ms - 1173
[HTTP]
[debug] [HTTP] Request idempotency key: 4803c8a6-416f-4b75-a6ce-8a4a7015fb04
[HTTP] --> POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/element
[HTTP] {“using”:“xpath”,“value”:"//
[@data-automation-id=‘inputLoginPassword’]"}
[debug] [Mac2Driver@be94 (42b68278)] Calling AppiumDriver.findElement() with args: [“xpath”,"//[@data-automation-id=‘inputLoginPassword’]",“42b68278-94c3-4f2e-94a2-32fd30c70cc4”]
[debug] [Mac2Driver@be94 (42b68278)] Valid locator strategies for this request: id, name, accessibility id, xpath, class name, -ios predicate string, predicate string, -ios class chain, class chain
[debug] [WD Proxy] Matched ‘/element’ to command name ‘findElement’
[debug] [WD Proxy] Proxying [POST /element] to [POST http:// 127.0.0.1:10100/session/E0174915-1FF5-4261-8FDF-189A53A5D600/element] with body: {“using”:“xpath”,“value”:"//
[@data-automation-id=‘inputLoginPassword’]"}
[debug] [WebDriverAgentMac] [xcodebuild] t = 5.54s Find the Application ‘com.apple.Safari’
[WD Proxy] Got response with status 404: {“value”:{“error”:“no such element”,“message”:"unable to find an element using ‘xpath’, value ‘//[@data-automation-id=‘inputLoginPassword’]’",“traceback”:"(\n\t0 WebDriverAgentLib 0x0000000105a212fc FBNoSuchElementErrorResponseForRequest + 252\n\t1 WebDriverAgentLib 0x0000000105a210a0 +[FBFindElementCommands handleFindElement:] + 380\n\t2 WebDriverAgentLib 0x0000000105a61f18 -[FBRoute_TargetAction mountRequest:intoResponse:] + 168\n\t3 WebDriverAgentLib 0x0000000105a5c180 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 652\n\t4 WebDriverAgentLib 0x0000000105a563f4 -[RoutingHTTPServer handleRoute:withRequest:response:] + 168\n\t5 WebDriverAgentLib 0x0000000105a56e3c __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t6 libdispatch.dylib 0x00000001a5890400 _dispatch_client_callout + 20\n\t7 libdispatch.dylib …
[debug] [W3C] Matched W3C error code ‘no such element’ to NoSuchElementError
[debug] [Mac2Driver@be94 (42b68278)] Encountered internal error running command: NoSuchElementError: unable to find an element using ‘xpath’, value '//
[@data-automation-id=‘inputLoginPassword’]’
[debug] [Mac2Driver@be94 (42b68278)] at errorFromW3CJsonCode (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1034:25)
[debug] [Mac2Driver@be94 (42b68278)] at ProxyRequestError.getActualError (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:909:14)
[debug] [Mac2Driver@be94 (42b68278)] at WDAMacProxy.command (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:340:19)
[debug] [Mac2Driver@be94 (42b68278)] at processTicksAndRejections (node:internal/process/task_queues:95:5)
[debug] [Mac2Driver@be94 (42b68278)] at Mac2Driver.findElOrEls (/Users/…/.appium/node_modules/appium-mac2-driver/lib/commands/find.js:17:10)
[debug] [Mac2Driver@be94 (42b68278)] at Mac2Driver.findElOrElsWithProcessing (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:66:14)
[debug] [Mac2Driver@be94 (42b68278)] at Mac2Driver.findElement (/opt/homebrew/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:13:12)
[HTTP] <-- POST /session/42b68278-94c3-4f2e-94a2-32fd30c70cc4/element 404 414 ms - 1173

I changed from Mac2Driver to SafariDriver and now it works.

I still dont know what I did wrong with Mac2Driver. Feel free to present a solution with Mac2Driver, as probably someone will someday run into the same problem.

My code now looks like this:

public static WebDriver GetRemoteSafariDriver(string IPAdress)
    {
        AppiumOptions capabilities = new AppiumOptions();
        capabilities.AutomationName = "Safari";
        capabilities.DeviceName = "tp-mac-01";
        capabilities.PlatformName = "Mac";
        capabilities.PlatformVersion = "13.3.1";
        
        AppiumDriver driver = new MacDriver(new Uri("http://"+IPAdress+":4723/"), capabilities, TimeSpan.FromMilliseconds(60000));
        driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(60000);
        return driver;
    }

You probably need to understand the concept of different drivers better. Mac2 driver is built on top of Apple’s xctest framework and uses system accessibility to interact with elements. It is a general-purpose tool for any macOS app automation while Safari driver uses WebDriver proxy to the Safari browser (and only to it). It has nothing to do to xctest and thus the internal elements representation there is completely different from mac2driver’s one.

1 Like

Thank you for the reply! Is Mac2Driver generally the wrong driver to automate websites or did i just used it in the wrong way to automate the website tests?
Did I get it right that Mac2Driver can be used to automate any mac app (like Finder or a selfmade app)? That would be probably something I’ll need in the future. Do you have Links to more Information about different Drivers and when and how to use them correctly? Especially for the Mac2Driver. I usually work with windows, so mac is a whole new world for me. It was hard to find anything at all about the Mac2Driver, apart from its documentation (which seems to expect its users to already know everything about the apple world).