Problem closing popover window. Javascript/WD/iOS

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;
}

to try:

  1. click is WEB. switch to tap:
  2. try also tap by coordinates if you use ‘touch-actions’ (second link)
1 Like

I have tried number 2, and it works. I will try number one, I have already use that for pinch and pan.

Where would I find the source to click()? I am curious as to why it is not working.

It is implemented in the appium server:

From: wd/lib/commands.js

this._jsonWireCall({
    method: 'POST'
    , relPath: '/click'
    , data: {button: button}
    , cb: simpleCallback(cb)
  });