启动Internet Explorer时出现意外错误。 IELaunchURL()使用Selenium 3.13.0返回HRESULT 80070012:IEDriverServer_x64_3.13.0

问题描述 投票:0回答:3

我的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.");
            }
        }
selenium internet-explorer selenium-webdriver selenium-iedriver iedriverserver
3个回答
0
投票

请尝试下面提到的步骤,然后尝试运行IE浏览器的自动化脚本。

  1. 仅对于IE 11,您需要在计算机的目标上设置一个注册表项,以便驱动程序可以维护与其创建的Internet Explorer实例的连接。对于32位Windows安装,您必须在注册表编辑器中检查的密钥是HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE。
  2. 对于64位Windows安装,密钥为HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE。

请注意,FEATURE_BFCACHE子项可能存在也可能不存在,如果不存在,则应创建该子项。在此键内,创建名为iexplore.exe的值为0的DWORD值。

所有区域的保护模式设置都相同。已禁用增强保护模式。


0
投票

根据错误日志,您使用的是Java 9. Selenium尚不支持Java 9。请更改设置以使用java 8,然后重试。它可以解决这个问题。


0
投票

此错误消息...

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/'

...暗示IEDriverServer无法启动/生成新的WebBrowser即IE浏览器会话。


根据Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') @JimEvans明确提到:

IELaunchURL()函数是一个Windows API。司机只是打电话给它。如果它返回错误,那就是问题所在。 Microsoft没有提供有关在使用此API时会导致此错误的文档。如果您尝试在Windows 10等工作站级操作系统上运行测试,而不是在Windows Server上运行,会发生什么?我意识到这不是一个“银弹”解决方案,但是服务器环境中可能存在安全设置,这些设置不在工作站环境中,这将阻止在该上下文中分配额外的文件句柄。


introduceFlakinessByIgnoringSecurityDomains();

正如您根据introduceFlakinessByIgnoringSecurityDomains(); @JimEvans添加选项You're Doing It Wrong: IE Protected Mode and WebDriver一样,明确提到添加options.introduceFlakinessByIgnoringSecurityDomains();可能会让您超过初始异常,并且允许测试在大多数情况下运行而不会发生意外。但是,使用此功能并不能解决潜在的问题。如果跨越保护模式边界,则可能会发生非常意外的行为,包括挂起,元素位置不起作用以及未传播的点击。


如果你看看qazxsw poi的qazxsw poi,可以清楚地提到以下几点:

保护模式

在Windows Vista或Windows 7上的Internet Explorer 7或更高版本上,必须将每个区域的“保护模式”设置设置为相同的值。只要每个区域的值相同,该值就可以打开或关闭。要设置保护模式设置,您必须从“工具”菜单中选择“Internet选项”,然后单击“安全”选项卡。对于每个区域,标签底部将显示一个标记为启用保护模式的复选框。

Required Configuration

浏览器缩放级别

浏览器缩放级别必须设置为100%,以便可以将本机鼠标事件设置为正确的坐标。

参考

您可以在以下位置找到一些详细的讨

© www.soinside.com 2019 - 2024. All rights reserved.