selenium: WebDriver v3.7.0 C# Firefox "missing handle parameter" for popup windows

OS: Windows Selenium Version: 3.7.0 Browser: RemoteWebDriver using Firefox v56.0.2 (or any recent Firefox) I am using GeckoDriver 0.19.1

Seems like this might be a C# binding issue in dotnet/src/webdriver/Remote/RemoteTargetLocator.cs where the SwitchTo().Window command is no longer transmitting the proper information expected by geckodriver?

The code below results in an Exception “Missing ‘handle’ parameter” when switching to the popup.

However, the test passes with Firefox 52.0.2, geckodriver 0.15.0, and WebDriver 3.3.x.

Steps to reproduce -

Here’s some HTML with a popup link: (test.html)

<HTML>
 <HEAD><TITLE>Firefox Popup Test Case</TITLE></HEAD>
 <BODY>
  <H1>Firefox Popup Test Case</H1>
   <A id="link" onClick="javascript:window.open('http://www.google.com', 'google');">
    Google Popup Link
   </A>
 </BODY>
</HTML>

Here’s some C# code with NuGets of Selenium.WebDriver v3.7.0 and NUnit 3.7.0:

using System;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium;
using System.Collections.ObjectModel;
using System.Linq;
using System.Collections.Generic;

namespace WebDriverTestProject
{
    /// <summary>
    /// 
    /// </summary>
    [TestFixture]
    public class UnitTest1
    {
        /// <summary>
        /// 
        /// </summary>
        [Test]
        public void TestMethod()
        {
            IWebDriver webdriver = null;
            try
            {
                DesiredCapabilities dc = DesiredCapabilities.Firefox();
                webdriver = new RemoteWebDriver(new Uri("http://hub:4444/wd/hub"), dc);

                // Popup page
                webdriver.Navigate().GoToUrl("http://webpage/test.html");

                ReadOnlyCollection<string> previousHandles = webdriver.WindowHandles;
                Console.WriteLine("Previous Popup count: " + previousHandles.Count);

                // Trigger popup
                webdriver.FindElement(By.Id("link")).Click();

                // Wait for popup
                do
                {
                    Console.WriteLine("Waiting for popup...");
                    System.Threading.Thread.Sleep(2000);
                } while (previousHandles.Count == webdriver.WindowHandles.Count);

                // Find the popup handle
                ReadOnlyCollection<string> currentHandles = webdriver.WindowHandles;
                IEnumerable<string> popupWindow = currentHandles.Except(previousHandles);
                Console.WriteLine("Popup is here! " + popupWindow.First());

                // Switch to window ====>>>> This is the line in error <<<<====
                webdriver.SwitchTo().Window(popupWindow.First());

                // Validate Google site
                System.Threading.Thread.Sleep(5000);
                Assert.True(webdriver.FindElements(By.CssSelector("input[name='q']")).Count > 0, "Could not find Google search field");
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("==EXCEPTION== " + e + "\n" + e.StackTrace);
                Assert.Fail(e.Message);
            }
            finally
            {
                webdriver.Quit();
            }
        }
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 46 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Folks, this is a grid/remote issue, not unique to the .NET bindings. It works locally, as mentioned by several commenters, and surfaces when using RemoteWebDriver.

Hitting this with Selenium python 3.8.0, Firefox 58, Geckodriver 0.18.0. Remote webdriver only. Runs great locally, fails on browserstack. Firefox only.

Need this fixed. It’s breaking our SauceLabs tests using latest Firefox browser and latest Selenium driver (3.11.0). Any other tip on workarounds or timeframe to fix RemoteWebDriver?

This is an issue which I’m experiencing when I run test on SauceLabs, so probably a remote webdriver issue. Running locally with Selenium 3.8.1, Firefox 58 and GeckoDriver 0.19.1, just works fine, but the same setup does not works on SauceLabs.

Any update on this? I am still getting this error with selenium 3.11 and gecko 0.20.1

org.openqa.selenium.WebDriverException: Missing ‘handle’ parameter Build info: version: ‘3.11.0’, revision: ‘47706e36d0’, time: ‘2018-04-12T17:34:58.597Z’ System info: host: ‘Flipboards-MacBook-Pro-3.local’, ip: ‘fe80:0:0:0:10d4:18d:9f8b:583c%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: ‘1.8.0_144’ Driver info: driver.version: unknown Command duration or timeout: 19 milliseconds Build info: version: ‘2.53.0’, revision: ‘35ae25b1534ae328c771e0856c93e187490ca824’, time: ‘2016-03-15 10:43:46’ System info: host: ‘Flipboards-MacBook-Pro-3.local’, ip: ‘172.31.10.222’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: ‘1.8.0_144’ Driver info: org.openqa.selenium.remote.RemoteWebDriver Capabilities [{moz:profile=/var/folders/r5/xsd59wl12g32smfydwvnwplw0000gn/T/rust_mozprofile.pPiG0p4qrIXN, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=ANY, moz:accessibilityChecks=false, moz:useNonSpecCompliantPointerOrigin=false, webdriver.remote.sessionid=6dfa7f98-f2f1-ee4d-98c0-6463d34607c1, acceptInsecureCerts=false, browserVersion=59.0.2, platformVersion=16.7.0, moz:processID=8389, browserName=firefox, platformName=darwin, moz:webdriverClick=true}] Session ID: 6dfa7f98-f2f1-ee4d-98c0-6463d34607c1

I am also facing similar issue with Firefox browser 57 and Selenium 3.8.0 on SauceLab

Same here. Was trying a variety of version combinations of Ghecko and Selenium - nothing have worked for me on Browserstack.

Same here, with SauceLabs, any other workaround?

We’ve got the same issue. It’s a Firefox related bug. The issue comes from the RemoteWebDriver.

Same issue trying to change between tabs (page.driver.browser.switch_to.window(window.first)) using the ruby version. And yes… the issue comes from the RemoteWebDriver