I am having a very strange problem.
In my app I have a popover window with a cancel button to close it. Clicking off the window closes it too. (This is all application logic)
The app works both on a real device and on the simulator. Running a test script under appium I can see the button “flex” as it is clicked (it changes colour briefly) but the window does not close.
I put this in a loop clicking the button 10 times, and waiting a second between each. I can interact with the app and click other buttons on the popover and they avct normally. If I click cancel
with the mouse nothing happens.
The application logic is different under Appium. What could be causing this?
This is how I click the cancel button
async function testCancel(driver){
// At the end of this function will be in Layouts mode
let cancel_but = await driver.elements('-ios class chain', '**/XCUIElementTypeButton[`label == "cancel"`]');
if(cancel_but === null){
return "FAIL: Cannot find cancel button";
}else{
await cancel_but[0].click();
if(await closedDatePicker(driver)){
return "SUCCESS";
}else{
return "FAIL";
}
}
}
async function closedDatePicker(driver) {
let date_picker_windows = await driver.elements('-ios predicate string', 'type == "XCUIElementTypePopover"');
if(date_picker_windows.length === 0){
return true;
}
return false;
}