[英]How to accept this alert in appium?
Appium v1.6.4-beta Xcode 8.2 macOs Sierra 10.12 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这是我想要允许的
How to accept this alert?如何接受此警报? I have tried with xpath sa well, but no luck我试过 xpath sa 很好,但没有运气
Below code will work.Give it a try with "OK" and "Ok".下面的代码将起作用。尝试使用“OK”和“Ok”。 This is because if you want to try to identify the element with the text you can use accessibilityID or ID.这是因为如果您想尝试使用文本标识元素,您可以使用 accessibilityID 或 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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.