Search code examples
c#seleniumselenium-webdriverwebdriverinternet-explorer-11

Multiple IE web-drivers : session lost when click link/button that opens a popup window



I run multiple (2) IE web-drivers together.(for user side and admin side tests) When the InternetExplorer WebDriver click on link/button that opens an modal popup, login page are opened on new window (abnormal).


When the ie webdriver popup the window , I can see for a fraction of a second the correct address the browser should load (in URL line) , but immediatly it changed to the login url, and required enter username and password.


I found the same problem in this link, I made the solution there, but I still have not solved the problem, and I get an entry window instead of the expected window. see this screenshot

  • My IE version is 11.
  • My Selenium.WebDriver is 3.141.0.0
  • My ie webdriver is IEDriverServer_x64_3.141.5


My InternetExplorerOptions:

 private static InternetExplorerOptions ieOptions = new InternetExplorerOptions
        {
            EnsureCleanSession = true ,
            EnableNativeEvents = true ,
            RequireWindowFocus = true ,
            EnablePersistentHover = true ,
            ForceCreateProcessApi = true ,
            BrowserCommandLineArguments = "-framemerging -private"
        };

I added the registry keys:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FrameMerging\(DWORD)00000000

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\TabProcGrowth\(DWORD)00000000

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE\iexplorer.exe\(DWORD)00000000

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE\iexplorer.exe\(DWORD)00000000


Edited:

By the Deepak-MSFT references, I understand that the issue caused by more than one IE web-driver instances.

I tried to kill the IE driver also by adding the ConfirmCleanSession = trueoption to the code, and also manually by running of the following statements from the command line (before running the test);

taskkill / F / IM iexplore.exe / T
taskkill / F / IM IEDriverServer.exe / T


But it did not help once I set 2 IE web-drivers to work together.

(When I tried to run the test only on one driver - it worked great!)


I would appreciate help in solving the problem!


Solution

  • This issue is due to a quirk of IE itself and how the driver creates the popup window for the browser.

    The workaround is to ensure there are no iexplore.exe processes running when you start the session with the driver.

    References:

    (1) session cookie lost when click made to a link that opens a window with window.open()

    (2) session cookie lost when click made to a link that opens a window with window.open()