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();
}
}
}
}
Issue still present with Selenium C# v3.8.0, Firefox 57.0.2, and GeckoDriver 0.19.1
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.
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.
I am facing the same issue. By any chance someone knows a workaround for remote webdriver? Works fine on localhost.
And guys, this is not only C#, but java as well, and probably all the platforms you support.
Does anyone has a useful workaround for now?
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.
Yes I agree with that. I am running in that issue with the Java bindings. And same problem in js: https://github.com/nightwatchjs/nightwatch/issues/1663
My test setup on Browserstack: geckodriver v0.19.1 selenium 3.10.0 Firefox v59.0
So does anyone has a workaround till a fix is implemented?
This workaround works for me:
dstepper/selenium@2da0105#diff-578329ec7273c4a024979fd0ebcda293
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
We've got the same issue. It's a Firefox related bug. The issue comes from the RemoteWebDriver.
Same here, with SauceLabs, any other workaround?
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?
Same here. Was trying a variety of version combinations of Ghecko and Selenium - nothing have worked for me on Browserstack.
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
Can anybody provide a reproduction scenario with a standalone selenium server (not SauceLabs or BrowserStack)?
I can't reproduce the issue using the scenario from original post.
@barancev I can not provide you such steps, but if that helps @dstepper seems to found already where the issue comes from: https://github.com/dstepper/selenium/commit/2da0105
According to the specification [1], a client binding should pass 'handle' property for a W3C conformant implementations, where as a legacy implementations require a 'name' property [2].
I can see the only reason for this issue: an implementation (say, SauceLabs) requires a 'handle' property, pretending it being W3C conformant, but it does not report W3C conformance during negotiation phase, and a client binding sends legacy payload.
If my guess is correct, the issue should be fixed on SauceLabs side.
[1] https://w3c.github.io/webdriver/webdriver-spec.html#switch-to-window [2] https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidwindow
Let's look at .Net binding, for which the issue was reported, there are two branches: https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/webdriver/Remote/RemoteTargetLocator.cs#L140 https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/webdriver/Remote/RemoteTargetLocator.cs#L177