Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在使用appium测试iOS应用程序时,如何关闭模式视图控制器_Java_Intellij Idea_Automated Tests_Appium - Fatal编程技术网

Java 在使用appium测试iOS应用程序时,如何关闭模式视图控制器

Java 在使用appium测试iOS应用程序时,如何关闭模式视图控制器,java,intellij-idea,automated-tests,appium,Java,Intellij Idea,Automated Tests,Appium,您好,我正在使用Intellij/Appium为我的iOS应用程序构建自动化测试 在我的Xcode iOS应用程序中,我向用户发出如下警报: [vc presentViewController:alertController animated:YES completion:nil]; 这只有一个OK按钮 有人能告诉我如何在java测试脚本中消除这个问题吗? 我正在使用以下代码,但它不起作用: Object alertBoxes = this.driver.findElementsByClass

您好,我正在使用Intellij/Appium为我的iOS应用程序构建自动化测试

在我的Xcode iOS应用程序中,我向用户发出如下警报:

[vc presentViewController:alertController animated:YES completion:nil];
这只有一个OK按钮

有人能告诉我如何在java测试脚本中消除这个问题吗? 我正在使用以下代码,但它不起作用:

Object alertBoxes = this.driver.findElementsByClassName("UIAAlertView");

if (alertBoxes instanceof ArrayList) {

    WebElement alertBox = (WebElement)((ArrayList)alertBoxes).get(0);

        if (alertBox.isDisplayed()) {

            alertBox.click();
        }
}

很明显,我对这一切都不熟悉,所以我希望我的问题是可以理解的。谢谢。

回答我自己的问题,这个解决方案很有效

this.driver.switchTo().alert().accept();
我不知道为什么这是有效的,点击不起作用。 (顺便说一句,我使用的是appium 1.6)