我的 selenium 测试用例在 internet explorer 11 浏览器上执行得很好,但是有些事情发生了变化,现在我得到了以下错误。
Started InternetExplorerDriver server (64-bit)
3.13.0.0
Listening on port 32274
Only local connections are allowed
[ERROR] [BaseTest] [startWebDriverClient] Could not start a new session. org.openqa.selenium.SessionNotCreatedException: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'http://localhost:32274/'
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'LUSMIN-F00Q46Y', ip: '***.**.**.**', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '9.0.1'
Driver info: driver.version: unknown
remote stacktrace:
at com.tcs.saf.base.BaseTest.startWebDriverClient(BaseTest.java:496)
at com.tcs.saf.base.BaseTest.beforeMethod(BaseTest.java:258)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:516)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
下面是我实例化 IE 浏览器的代码;
if (browserType.equalsIgnoreCase("InternetExplorer")) {
try {
System.setProperty("webdriver.ie.driver", curProj+"\\drivers\\IEDriverServer.exe");
InternetExplorerOptions options = new InternetExplorerOptions();
options.introduceFlakinessByIgnoringSecurityDomains();
options.requireWindowFocus();
webdriver = new InternetExplorerDriver(options);
logger.info("getWebDriver - Setting webdriver.ie.driver system property as: " + System.getProperty("webdriver.ie.driver"));
} catch(IllegalStateException e) {
logger.error("The path to the driver executable must be set by the webdriver.ie.driver system property. ",e.fillInStackTrace());
throw new IllegalStateException("The path to the driver executable must be set by the webdriver.ie.driver system property.");
}
}