Selenium Webdriver运行时异常:意外警告“请关闭应用程序的其他打开的选项卡并重新打开此活动”,即使没有其他选项卡打开。自动化脚本工作得很好,但最近我得到了上面的exception.The警报屏幕截图:

我尝试了不同版本的chrome,selenium独立驱动,但问题仍然存在。即使应用程序没有在除联机执行之外的任何选项卡或浏览器中打开,为什么会出现此警报?
发布于 2017-03-30 17:01:47
如果这个弹出窗口每次都出现在某个特定的位置,那么你可以通过写下下面的几行代码来接受它:
WebDriver wb=new ChromeDriver();
wb.switchTo().alert().accept();否则,如果在初始化驱动程序时出现任何意外的弹出窗口,则可以使用以下代码:
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
String path=new GetBasePath().getPath_XML()+dir;
prefs.put("download.default_directory", path);
options.addArguments("disable-extensions");
prefs.put("credentials_enable_service", false);
prefs.put("password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
options.addArguments("chrome.switches","--disable-extensions");
options.addArguments("--test-type");
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, options);
cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
System.setProperty("webdriver.chrome.driver",**path to chromedriver.exe**"));
WebDriver wb= new ChromeDriver(cap);我个人的意见是,两者都用。
https://stackoverflow.com/questions/42991997
复制相似问题