无法使用 Selenium/Appium 单击警报 [英] Unable to click on Alert with Selenium/Appium
问题描述
我有一个带有确定按钮的警报,我需要单击它,但我尝试过的任何内容似乎都不起作用.我的代码可以识别警报,但是一旦我尝试执行它的操作,它似乎就会与警报后面的屏幕进行交互.
I have an alert with a OK button that I need to click, but nothing I've tried seems to work on it. My code can identify the alert, but as soon as I try to perform an action it, it seems to interact with the screen behind the alert.
这是我正在使用的原生 iOS 应用.我尝试了以下选项:
It's a native iOS app that I'm working with. I've tried the following options:
1. driver.switchTo().alert().accept();
2. driver.switchTo().alert().dismiss;
3. driver.switchTo().alert();
driver.findelement(By.id("OK")).click();
4. TouchAction touchAction = new TouchAction(driver).tap(xCoordinates, yCoordinates);
touchAction.perform();
有人知道点击此提醒的另一种方法吗?
Does anyone know of another way to click on this alert?
推荐答案
在 appium 您的能力列表中添加能力 capabilities.setCapability("autoGrantPermissions", true);!它将允许自动接受或确定.我的同样问题已解决!
Add a capability capabilities.setCapability("autoGrantPermissions", true); in appium your capabilities list! It will allow to accept or OK automatically. My same issue was resolved!
这篇关于无法使用 Selenium/Appium 单击警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!