gpt4 book ai didi

testing - 捕获警报的屏幕截图

转载 作者:行者123 更新时间:2023-11-28 19:48:57 25 4
gpt4 key购买 nike

我使用下面的代码在弹出窗口出现后截取应用程序的屏幕截图。

Alert alert = driver.switchTo().alert();
File scrFile= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("G:\\Screens\\sc1.jpg"));
String alertMsg = alert.getText();
System.out.println(alertMsg);
alert.accept();

但是它抛出了这个异常

Exception in thread "main" org.openqa.selenium.UnhandledAlertException:Modal dialog present: Assessment Name already Exist.

但是如果我删除屏幕截图程序,代码可以正常工作。

最佳答案

您必须在截取屏幕截图之前处理警报...您可以在此处阅读更多信息 https://code.google.com/p/selenium/issues/detail?id=4412

关于testing - 捕获警报的屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21670361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com