当我打开Web应用程序时,我会弹出一个窗口。我试图以两种方式单击“允许”按钮:
1)当我添加权限时:
caps.setCapability("autoGrantPermissions", true);
caps.setCapability("autoAcceptAlerts", true);
......
driver.switchTo().alert().accept();
没发生什么事((
2)当我尝试通过XPath查找它时:
driver.findElement(By.xpath("//android.widget.Button[@text='Allow']")).click();
我收到一个错误:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//android.widget.Button[@text='Allow']"}
这是我从UI Automator Viewer截取的屏幕截图:
相关分类