如何在 appium 中接受此警报?

编程入门 行业动态 更新时间:2024-10-27 19:28:43
本文介绍了如何在 appium 中接受此警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

Appium v​​1.6.4-betaXcode 8.2macOS 塞拉利昂 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.

这是我的剧本

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

也使用了功能,

 capabilities.setCapability("autoAcceptAlerts", true);

这是我想要的

如何接受这个提醒?我已经很好地尝试了 xpath sa,但没有运气

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

推荐答案

下面的代码将起作用.尝试使用OK"和Ok".这是因为如果您想尝试用文本标识元素,您可以使用accessibilityID 或ID.

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();

这篇关于如何在 appium 中接受此警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 18:35:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/919123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   如何在   appium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!