OpenQA.Selenium.WebDriverException after Impersonation

Won’t fix Issue #10497256

Details

Author
Rico S.
Created
Jan 11, 2017
Privacy
This issue is public.
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I am using WrapperImpersonationContext class to impersonate a new user to run my Selenium Scripts. In other words simulating Run IE as different user.

However, I get the following exception when I try to initiate my IWebDriver.

Exception thrown: ‘OpenQA.Selenium.WebDriverException’ in WebDriver.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>FIM_Selenium.vshost.exe</AppDomain><Exception><ExceptionType>OpenQA.Selenium.WebDriverException, WebDriver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null</ExceptionType><Message>A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:20972/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.</Message><StackTrace> at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver…ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)

This is my code.

private void button1_Click(object sender, EventArgs e)
    {

        using (WrapperImpersonationContext context = new WrapperImpersonationContext("MyDomain", "My Username", "My Password"))
        {
            Console.WriteLine("Current user: " +WindowsIdentity.GetCurrent().Name);
            context.Enter();
            Console.WriteLine("Current user: " + WindowsIdentity.GetCurrent().Name);

            String IE_DRIVER_PATH;
            String url = "http://www.domain.nl/";

            if (Environment.Is64BitOperatingSystem)
            {
                IE_DRIVER_PATH = @"C:\software\selenium\drivers\64\";
            }
            else
            {
                IE_DRIVER_PATH = @"C:\software\selenium\drivers\32\";
            }
            var options = new InternetExplorerOptions()
            {
                InitialBrowserUrl = url,
                IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                IgnoreZoomLevel = true
            };

            IWebDriver driver = new InternetExplorerDriver(IE_DRIVER_PATH, options, TimeSpan.FromMinutes(1));
            Thread.Sleep(1000);
            context.Dispose();
            Console.WriteLine("Current user: " + WindowsIdentity.GetCurrent().Name);
        }


    }

What am I doing wrong or what can I do to get this resolved?

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Ibrahim O.”

      Changed Assigned To to “Brad E.”

      Changed Status to “Won’t fix”

    • Hello,

      Thank you for providing your feedback on IE11. We are not accepting feedback on Internet Explorer through this portal any longer (unless security related). We welcome any feedback you have on Microsoft Edge through this website.

      Best Wishes,
      The MS Edge Team

    You need to sign in to your Microsoft account to add a comment.

    Sign in