如何使用 appium 读取 android 中的警报消息内容?
How to read alert message content in android using appium?
目前我正在使用以下方法读取警报消息内容,但它会抛出错误提示尚未实现。实现这一目标的替代方法是什么?
driver1.switchTo().alert().getText();
错误:org.openqa.selenium.WebDriverException:尚未实施。请帮助我们:http://appium.io/get-involved.html(警告:服务器未提供任何堆栈跟踪信息)
在 appium 中不需要使用 switchto.alert 方法来捕获警报消息。移动设备中的警报消息实际上位于本机上下文中,您必须切换到本机上下文才能访问警报 buttons/text.
driver1.context("NATIVE_APP");
之后,您可以将警报捕获为本机元素并对其触发任何操作。例如:
driver1.findElement(By.xpath("//android.widget.Button[@text='Yes']")).click();
目前我正在使用以下方法读取警报消息内容,但它会抛出错误提示尚未实现。实现这一目标的替代方法是什么?
driver1.switchTo().alert().getText();
错误:org.openqa.selenium.WebDriverException:尚未实施。请帮助我们:http://appium.io/get-involved.html(警告:服务器未提供任何堆栈跟踪信息)
在 appium 中不需要使用 switchto.alert 方法来捕获警报消息。移动设备中的警报消息实际上位于本机上下文中,您必须切换到本机上下文才能访问警报 buttons/text.
driver1.context("NATIVE_APP");
之后,您可以将警报捕获为本机元素并对其触发任何操作。例如:
driver1.findElement(By.xpath("//android.widget.Button[@text='Yes']")).click();