简体   繁体   中英

How to click "OK"on IOS alert box using Appium 1.21.0 on Simulator?

I'm writing a test using Java & Appium 1.21.0. I'm unable to click "OK" button on alert box to close the popup on the Simulator iPhone.

I tried the following code:

Actions action = new Actions(getDriver());
action.moveToElement(getDriver().findElement(By.xpath("//XCUIElementTypeButton[@name=\"OK\"]")));
action.click();
action.perform();

The above code is not working.

Using the following:

  • Appium 1.21.0
  • Xcode 14.0.1 - running simulator iPhone 8

You can try this one:

caps.setCapability("autoAcceptAlerts", "true"); //to accept all alerts //OR caps.setCapability("autoDissmissAlerts", "true"); //to dismiss all alerts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM