-1

I am running selenium script in IE11 on windows 10 an getting below whenever i try to switch to a new window:

  1. Error retrieving current window
  2. Unable to get browser

However the same code is running fine in IE11 on windows 7. I have tried changing regedit for IE tried setting capabilities. Still facing the issue. Can anyone kindly suggest a workaround for this issue?

James Z
  • 12,209
  • 10
  • 24
  • 44
Aman
  • 1
  • Which version of IE11 are running on both hosts? Which Selenium version are you using? Show us how you setup the iedriver. – AndiCover Aug 20 '19 at 18:34

1 Answers1

0

It is recommended to post a sample code when you post any question may help community members to understand the issue and help to make a tests.

You said that you had modified some registry settings. I suggest you to reset those registries and reset IE browser again.

Try to use C# code example below may help to switch window.

//switch to new window.
driver.SwitchTo().Window(driver.WindowHandles.Last());

//if you want to switch back to your first window
driver.SwitchTo().Window(driver.WindowHandles.First());

Below is an C# example for switch to new window by comparing the title of the window.

protected static Boolean SwitchWindow(string title)
            {
                var currentWindow = driver.CurrentWindowHandle;
                var availableWindows = new List<string>(driver.WindowHandles);

                foreach (string w in availableWindows)
                {
                    if (w != currentWindow)
                    {
                        driver.SwitchTo().Window(w);
                        if (driver.Title == title)
                            return true;
                        else
                        {
                            driver.SwitchTo().Window(currentWindow);
                        }

                    }
                }
                return false;
            }

References:

(1) Selenium WebDriver in C#: Switch To new window or tab

(2) How can I switch to new window using webdriver?

(3) Selenium webdriver selecting new window c#

If issue persists than try to provide detailed information about your issue. We will try to test the issue to find the cause for the issue.

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19