Hi all, I am facing a weird issue while testing on IOS.
Running IOS 15.2 on iPhone 13 simulator.
Appium version is: 1.22.2
The issue happened for about 3 times in the last 5 days so it will be hard for me to test it…
The issue is as so:
The issue happens each time on the same page with the same button! (any other time it works!)
I am locating an element using POM appium annotations (@iOSXCUITFindBy annotation).
Then, waiting for it to be clickable using WebDriverWait and ExpectedConditions class.
And then click it.
The problem is that in reality, another element is being clicked on the page and the test fails.
I will specify some code bellow but please note that it happens rarely (maybe some race condition…)
and when looking on appium logs and comparing it with a successful test, they are the same.
I can see that a ‘…/click’ request is being sent to appium with the correct element and appium does not even try to locate the wrong element(the one who is being clicked).
My code:
Locating the element:
@HowToUseLocators(androidAutomation = ALL_POSSIBLE, iOSXCUITAutomation = ALL_POSSIBLE)
@iOSXCUITFindBy(id = “next”) @iOSXCUITFindBy(id = “Next”) @iOSXCUITFindBy(id = “done”)
private WebElement nextBtn;
Clicking it:
public void clickNext(){wait.until(elementToBeClickable(nextBtn)).click();}
Some of appium logs: (all logs are after the WebDriverWait instance checked they are displayed and enabled, for both it is ‘true’)
Successful:
08:33:57 [debug] [WD Proxy] Proxying [POST /element/0B000000-0000-0000-472E-000000000000/element] to [POST http://127.0.0.1:8100/session/81CC5F5B-09C7-4053-8B4F-93FDA43C0AB6/element/0B000000-0000-0000-472E-000000000000/element] with body: {“using”:“id”,“value”:“Next”}
08:33:57 [debug] [WD Proxy] Got response with status 200: {“value”:{“ELEMENT”:“DE070000-0000-0000-472E-000000000000”,“element-6066-11e4-a52e-4f735466cecf”:“DE070000-0000-0000-472E-000000000000”},“sessionId”:“81CC5F5B-09C7-4053-8B4F-93FDA43C0AB6”}
08:33:57 [debug] [W3C (8a24db39)] Responding to client with driver.findElementFromElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“DE070000-0000-0000-472E-000000000000”,“ELEMENT”:“DE070000-0000-0000-472E-000000000000”}
08:33:57 [HTTP] <-- POST /wd/hub/session/8a24db39-e247-4433-92fc-e584c38bc871/element/0B000000-0000-0000-472E-000000000000/element 200 155 ms - 137
08:33:57 [HTTP]
08:33:57 [HTTP] --> POST /wd/hub/session/8a24db39-e247-4433-92fc-e584c38bc871/element/DE070000-0000-0000-472E-000000000000/click
08:33:57 [HTTP] {“id”:“DE070000-0000-0000-472E-000000000000”}
08:33:57 [W3C (8a24db39)] Driver proxy active, passing request on via HTTP proxy
08:33:57 [debug] [XCUITest] Executing command ‘proxyReqRes’
08:33:57 [debug] [WD Proxy] Matched ‘/wd/hub/session/8a24db39-e247-4433-92fc-e584c38bc871/element/DE070000-0000-0000-472E-000000000000/click’ to command name ‘click’
08:33:57 [debug] [WD Proxy] Proxying [POST /wd/hub/session/8a24db39-e247-4433-92fc-e584c38bc871/element/DE070000-0000-0000-472E-000000000000/click] to [POST http://127.0.0.1:8100/session/81CC5F5B-09C7-4053-8B4F-93FDA43C0AB6/element/DE070000-0000-0000-472E-000000000000/click] with body: {“id”:“DE070000-0000-0000-472E-000000000000”}
08:33:57 [debug] [WD Proxy] Got response with status 200: {“value”:null,“sessionId”:“81CC5F5B-09C7-4053-8B4F-93FDA43C0AB6”}
08:33:57 [WD Proxy] Replacing sessionId 81CC5F5B-09C7-4053-8B4F-93FDA43C0AB6 with 8a24db39-e247-4433-92fc-e584c38bc871
08:33:57 [HTTP] <-- POST /wd/hub/session/8a24db39-e247-4433-92fc-e584c38bc871/element/DE070000-0000-0000-472E-000000000000/click 200 227 ms - 65
08:33:57 [HTTP]
Unsuccessful:
06:34:00 [debug] [WD Proxy] Proxying [POST /element/0B000000-0000-0000-9E20-000000000000/element] to [POST http://127.0.0.1:8100/session/E7691ECA-7FBF-49C9-AFFC-6F479E3B04C7/element/0B000000-0000-0000-9E20-000000000000/element] with body: {“using”:“id”,“value”:“Next”}
06:34:00 [debug] [WD Proxy] Got response with status 200: {“value”:{“ELEMENT”:“DB070000-0000-0000-9E20-000000000000”,“element-6066-11e4-a52e-4f735466cecf”:“DB070000-0000-0000-9E20-000000000000”},“sessionId”:“E7691ECA-7FBF-49C9-AFFC-6F479E3B04C7”}
06:34:00 [debug] [W3C (636ac383)] Responding to client with driver.findElementFromElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“DB070000-0000-0000-9E20-000000000000”,“ELEMENT”:“DB070000-0000-0000-9E20-000000000000”}
06:34:00 [HTTP] <-- POST /wd/hub/session/636ac383-7022-4e44-bb88-f41e0e7d47b5/element/0B000000-0000-0000-9E20-000000000000/element 200 155 ms - 137
06:34:00 [HTTP]
06:34:00 [HTTP] --> POST /wd/hub/session/636ac383-7022-4e44-bb88-f41e0e7d47b5/element/DB070000-0000-0000-9E20-000000000000/click
06:34:00 [HTTP] {“id”:“DB070000-0000-0000-9E20-000000000000”}
06:34:00 [W3C (636ac383)] Driver proxy active, passing request on via HTTP proxy
06:34:00 [debug] [XCUITest] Executing command ‘proxyReqRes’
06:34:00 [debug] [WD Proxy] Matched ‘/wd/hub/session/636ac383-7022-4e44-bb88-f41e0e7d47b5/element/DB070000-0000-0000-9E20-000000000000/click’ to command name ‘click’
06:34:00 [debug] [WD Proxy] Proxying [POST /wd/hub/session/636ac383-7022-4e44-bb88-f41e0e7d47b5/element/DB070000-0000-0000-9E20-000000000000/click] to [POST http://127.0.0.1:8100/session/E7691ECA-7FBF-49C9-AFFC-6F479E3B04C7/element/DB070000-0000-0000-9E20-000000000000/click] with body: {“id”:“DB070000-0000-0000-9E20-000000000000”}
06:34:00 [debug] [WD Proxy] Got response with status 200: {“value”:null,“sessionId”:“E7691ECA-7FBF-49C9-AFFC-6F479E3B04C7”}
06:34:00 [WD Proxy] Replacing sessionId E7691ECA-7FBF-49C9-AFFC-6F479E3B04C7 with 636ac383-7022-4e44-bb88-f41e0e7d47b5
06:34:00 [HTTP] <-- POST /wd/hub/session/636ac383-7022-4e44-bb88-f41e0e7d47b5/element/DB070000-0000-0000-9E20-000000000000/click 200 237 ms - 65
06:34:00 [HTTP]
Appium inspector photo:
in purple the element who is in fact being clicked - the back arrow button on the screen.
in red the element who is located and the ‘…/click’ request is being sent to appium with its elementId - the ‘Next’ button on the screen
Please let me know if you see something I do not or if you ever experienced a similar issue.
Thanks a lot!