我的项目包括 Selenium webdriver、JAVA、Maven、TestNG、Jenkins、Allure(报告)。我有一些包含 100 多个测试用例的测试套件,我通过 3 个不同的浏览器对它们进行迭代(测试使用 TestNG 并行运行)。
有一项测试无法通过,除非我真的在看窗口并看到测试运行。
我将解释:我要测试什么?我们的 JS 开发人员创建了一项功能,即只有当用户将注意力集中在窗口上时,图像幻灯片才会开始移动和更改图像。
在 Firefox 和 Chrome 上它通过了很好 - 我不需要看测试。焦点可以在其他选项卡或浏览器上,驱动程序将模拟所有内容。在 IEdriver 上它不是那样的!
我尝试向驱动程序添加许多功能,但仍然没有(其中一些解决了我其他一些问题):
}else if (browser.equalsIgnoreCase("ie")) {
String exeServiceIEdriver = Consts.ieDriverPath;
System.setProperty("webdriver.ie.driver", exeServiceIEdriver);
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability("nativeEvents", false);
ieCapabilities.setCapability("unexpectedAlertBehaviour", "accept");
ieCapabilities.setCapability("ignoreProtectedModeSettings", true);
ieCapabilities.setCapability("disable-popup-blocking", true);
ieCapabilities.setCapability("enablePersistentHover", true);
ieCapabilities.setCapability("ignoreZoomSetting", true);
//ieCapabilities.setCapability("version", "12"); does it work?? don't think so..
ieCapabilities.setCapability("requireWindowFocus", true);
//ieCapabilities.setCapability("browser_version", "9.0"); // Does NOT work. need user agent
ieCapabilities.setCapability("IE_ENSURE_CLEAN_SESSION", true); // Does NOT work. need user agent
ieCapabilities.setCapability("browserAttachTimeout",5000);
ieCapabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS,true);
ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,true);
ieCapabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE,false);
driver = new InternetExplorerDriver(ieCapabilities);
Log.info("\n*** Starting IE Browser ***");