Unexpected error launching Internet Explorer. IELa

2020-04-02 05:52发布

My selenium test cases were executing just fine on internet explorer 11 browser but some thing got changed and now I'm getting the below error.

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)

Below is my code for instantiating the IE browser;

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.");
            }
        }

3条回答
看我几分像从前
2楼-- · 2020-04-02 06:30

As per the error log, you are using java 9. Selenium doesn't support Java 9 yet. Please change the settings to use the java 8 and try again. It may resolve the issue.

查看更多
男人必须洒脱
3楼-- · 2020-04-02 06:36

This error message...

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

...implies that the IEDriverServer was unable to initiate/spawn a new WebBrowser i.e. IE Browser session.


As per Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') @JimEvans clearly mentions:

The IELaunchURL() function is a Windows API. The driver simply calls it. If it's returning an error, then that's where the issue is. There is no documentation provided by Microsoft about what would cause this error when using this API. If you attempt to run the test on a workstation-class OS like Windows 10, instead of on Windows Server, what happens? I realize that's not a "silver-bullet" solution, but there may be security settings at play in the server environment that are not in the workstation environment that would prevent additional file handles from being allocated in that context.


introduceFlakinessByIgnoringSecurityDomains();

As you have added the option introduceFlakinessByIgnoringSecurityDomains(); as per You're Doing It Wrong: IE Protected Mode and WebDriver @JimEvans again clearly mentions that adding options.introduceFlakinessByIgnoringSecurityDomains(); may get you past the initial exception and will allow the test to run in most cases without incident. However using this capability doesn't solve the underlying problem though. If a Protected Mode Boundary is crossed, very unexpected behavior including hangs, element location not working, and clicks not being propagated, could occur.


Solution

If you look into the Required Configuration of Internet Explorer Driver the folowing points are clearly mentioned :

Protected Mode

On Internet Explorer 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings you have to choose "Internet Options" from the "Tools" menu and then click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled Enable Protected Mode.

ProtectedModeSettings

Browser Zoom Level

The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

References

You can find some detailed discussion in:

查看更多
啃猪蹄的小仙女
4楼-- · 2020-04-02 06:38

Please try the steps mentioned below and then try to run the automation script for IE Browser.

  1. For IE 11 only, you will need to set a registry entry on the target the computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

  2. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Inside this key, create a DWORD value named iexplore.exe with the value of 0.

Protected mode settings are the same for all zones. Enhanced Protected Mode is disabled.

查看更多
登录 后发表回答