1

Appium v1.6.4-beta Xcode 8.2 macOs Sierra 10.12

I want to automate to save photo in my device. But in first time I have to give permission. I have used "accept alert", but cannot accept the alert for allow to access the photo library. It shows the test passed in green , when I execute the test, but this popup still appear in view and photo is not saved.

This is my script

//Check Save 
driver.findElement(By.id("Save")).click();
driver.switchTo().alert().accept();

Capabilities also used ,

 capabilities.setCapability("autoAcceptAlerts", true);

This is what I want to allow

enter image description here

How to accept this alert? I have tried with xpath sa well, but no luck

Harshal Valanda
  • 5,331
  • 26
  • 63

1 Answers1

2

Below code will work.Give it a try with "OK" and "Ok". This is because if you want to try to identify the element with the text you can use accessibilityID or ID.

driver.findElement(By.id("OK")).click();

Below code won't work for alerts coming in mobile automation like web alerts.

driver.switchTo().alert().accept();
SaiPawan
  • 1,189
  • 7
  • 20
  • 1
    Thanks a lot. In my case, I handle alert of iOS Safari by change context to NATIVE_APP. Then find ID of "Open" to click. After that, I need to back to WEBVIEW_** context by driver.context(driver.getContextHandles().toArray()[1]); – Long Nguyen Mar 30 '18 at 01:32