Hello everyone,
I am stuck and thought I will ask here as I normally find older support requests by others that help me later on.
Details for my environment:
Appium Server: 2.6.0
XCUITest: 7.17.3
Appium Java Client: 9.2.3
Test device: iPhone 15, iOS 17.5.1.
The tests are written in Kotlin. Capability âautoWebviewâ is enabled.
We wrote a hybrid shopping app, meaning we need to switch between native and webview contexts all the time. Inside the iOS app code, we created an own JS method called getSafariId() that returns the ID of the webview context that gets returned when using driver.contextHandles.
For example when the context handle is WEBVIEW_15292.1, the according webview ID is A5E0FE7A-5B25-486C-AAD1-CEF15A5A1D8F.
The webview ID is also found in the native tree so we can compare and see which webview is the one we need to access. Itâs a bit complicated.
But now to my point.
For a while now itâs not possible anymore to get the webview ID via this getSafariId() method. Running it goes in a timeout after about two minutes (which should be more than enough, normally it worked almost instantly). Using the Safari dev tools on the local Macbook works, meaning that the method itself apparently isnât broken. The ID is still found in the native tree and the webview contexts can be found, the only issue is the ID of the webview context.
Has anyone of you ever used a method inside an app that you wrote yourself and does it still work?
PS: The error stack in the appium console looks extremely weird, but I will provide it here as well.
[RemoteDebugger] Starting to listen for JavaScript console
[RemoteDebugger] Starting to listen for network events
[XCUITestDriver@cc27 (89bafdd0)] Responding to client with driver.setContext() result: null
[HTTP] â POST /wd/hub/session/89bafdd0-170a-4b7d-92b9-dcf637b94400/context 200 11024 ms - 14
[HTTP]
[HTTP] â POST /wd/hub/session/89bafdd0-170a-4b7d-92b9-dcf637b94400/execute/sync
[HTTP] {âargsâ:,âscriptâ:âgetSafariId()â}
[XCUITestDriver@cc27 (89bafdd0)] Calling AppiumDriver.execute() with args: [âgetSafariId()â,,â89bafdd0-170a-4b7d-92b9-dcf637b94400â]
[XCUITestDriver@cc27 (89bafdd0)] Executing command âexecuteâ
[RemoteDebugger] Executing atom âexecute_scriptâ with âargs=[âgetSafariId()â,]; frames=â
[RemoteDebugger] Executing âexecute_scriptâ atom in default context
[RemoteDebugger] Sending javascript command: â(function(){return (function(){var e=this||selfâŚâ
[RemoteDebugger] Sending â_rpc_forwardSocketData:â message to app âPID:15292â, page â1â, target âpage-8â (id: 34): âRuntime.evaluateâ
[XCUITestDriver@cc27 (89bafdd0)] Matched â/alert/textâ to command name âgetAlertTextâ
[XCUITestDriver@cc27 (89bafdd0)] Proxying [GET /alert/text] to [GET http://127.0.0.1:8100/session/E89D3E9D-9C0A-466A-A796-764286472EA5/alert/text] with no body
[XCUITestDriver@cc27 (89bafdd0)] Got response with status 404: {âvalueâ:{âerrorâ:âno such alertâ,âmessageâ:âAn attempt was made to operate on a modal dialog when one was not openâ,âtracebackâ:ââ},âsessionIdâ:âE89D3E9D-9C0A-466A-A796-764286472EA5â}
[W3C] Matched W3C error code âno such alertâ to NoSuchAlertError