Driver command findElements not wait for implicit wait on iOS real devices
The problem
When call driver.findElements on iOS real device for not existed element it return empty list immediately without implicit wait.
Environment
- Java client version: latest (7.3.0)
- Appium server version: latest (1.18.3)
- Desktop OS/version: MacOS Catalina 10.15.7
- Node.js version: 12.18.3
- Mobile platform/version: iOS 14.1
- Real device or emulator/simulator: real
- Browser: Mobile Safari
Details
It works good for Android real device. It will wait implicitly while elements not appear and only after wait it will return an empty list. In my tests implicit wait is 10 seconds.
Code To Reproduce Issue
@Test
public void test() {
long currentTime = System.currentTimeMillis();
System.out.println("Current time is: " + currentTime);
// searching for not existed element
List<WebElement> elements = driver.findElements(By.xpath("//div[@data='qwe']"));
long newTime = System.currentTimeMillis();
System.out.println("List size is: " + elements.size());
System.out.println("Searching time is: " + (newTime - currentTime));
}
and the output for iOS:
Current time is: 1605221670415
List size is: 0
Searching time is: 75
output for Android real device:
Current time is: 1605221857411
List size is: 0
Searching time is: 10113
The driver instance is created using DesiredCapabilities as per docs. No rocket science there.
Appium Logs
Appium logs for iOS:
[HTTP] --> POST /wd/hub/session/ffd8db4c-033e-4416-a8fb-2ce1c339667e/elements
[HTTP] {"using":"xpath","value":"//div[@data='qwe']"}
[debug] [W3C (ffd8db4c)] Calling AppiumDriver.findElements() with args: ["xpath","//div[@data='qwe']","ffd8db4c-033e-4416-a8fb-2ce1c339667e"]
[debug] [XCUITest] Executing command 'findElements'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 10000 ms for condition
[debug] [RemoteDebugger] Executing atom 'find_elements'
[debug] [RemoteDebugger] Executing 'find_elements' atom in default context
[debug] [RemoteDebugger] Sending javascript command: '(function(){return function(){var k=this;functi...'
[debug] [RemoteDebugger] Sending '_rpc_forwardSocketData:' message to app 'PID:17715', page '1', target 'page-7' (id: 86): 'Runtime.evaluate'
[debug] [RemoteDebugger] Received data response from send (id: 86): '"{\"status\":0,\"value\":[]}"'
[debug] [RemoteDebugger] Sending to Web Inspector took 12ms
[debug] [RemoteDebugger] Received result for atom 'find_elements' execution: []
[debug] [W3C (ffd8db4c)] Responding to client with driver.findElements() result: []
[HTTP] <-- POST /wd/hub/session/ffd8db4c-033e-4416-a8fb-2ce1c339667e/elements 200 16 ms - 12
Appium logs for Android:
[HTTP] --> POST /wd/hub/session/d7767ea4-7ff3-4413-badd-1bb42e5a82a8/elements
[HTTP] {"using":"xpath","value":"//div[@data='qwe']"}
[W3C (d7767ea4)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/d7767ea4-7ff3-4413-badd-1bb42e5a82a8/elements' to command name 'findElements'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/d7767ea4-7ff3-4413-badd-1bb42e5a82a8/elements] to [POST http://127.0.0.1:8000/wd/hub/session/95b24beb4b590801c79dbc8ca726ea8d/elements] with body: {"using":"xpath","value":"//div[@data='qwe']"}
[debug] [WD Proxy] Got response with status 200: {"value":[]}
[HTTP] <-- POST /wd/hub/session/d7767ea4-7ff3-4413-badd-1bb42e5a82a8/elements 200 10093 ms - 12
@mykola-mokhnach Any updates?
No updates from my side, I don't have much exp with this part of code.
@mykola-mokhnach maybe you can tag someone who worked with this part of code before?
I filed a similar issue in the WDIO repository a while back, with a couple of examples if it helps: https://github.com/webdriverio/webdriverio/issues/5307
In my experience with that example, I was able to reproduce the issue on both Android and iOS. Not sure if something may have changed with Appium driver since that may have fixed it for Android.
@RomanShmandrovskyi are you using json-wire protocol or w3c in your capabilities? I was running into the above issue using w3c (webdriver) mode. I was able to work around by switching back to json-wire protocol. The issue has prevented me from using any w3c sessions.
@esaari actually, I'm not configure this capability in my project. So, think it use the default one.