I am using Selenium with the Internet Explorer Web Driver (IEDriverServer). For some reason I can't find the code base for it to open up this bug there. So if anyone can point me in that direction as well I would appreciate it.
This issue seems to be wide spread across all the drivers, which would indicate a base Selenium issue. But Selenium has already denied it is their problem. Currently there seems to be a fairly wide variety of hacks people have used to overcome the ongoing issue.
One person here on SO seems to have a similar issue, with a recommendation to overcome the issue by increasing the timeout, which sounds like a horrible idea to me because that would just slow down my tests overall.
I am getting these exceptions:
Message: The HTTP request to the remote WebDriver server for URL http://localhost:24478/session/07896235-84ea-465e-a361-cb0ef5885ef2/url timed out after 60 seconds. StackTrace: at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) 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.get_Url()
and
Message: The HTTP request to the remote WebDriver server for URL http://localhost:24478/session/07896235-84ea-465e-a361-cb0ef5885ef2/window/rect timed out after 60 seconds. StackTrace: at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) 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.RemoteWindow.get_Position()
I am getting this on a couple of different random calls to the driver. Like when I try and get the browsers current Url, or when I try and Click on an element in the browser.
In my current testing so far it looks like my tests are able to recover themselves and continue on, so future actions are still taken. I've got a few hacks I am going to try still, but it will take days to implement and test them giving the randomness of the issue.
I am using the Nuget Selenium.WebDriver package v3.141.0 with IEDriverServer v3.8. I rolled back from v3.9 due to another known issue with the driver.
Does anyone know of a fix to this issue, or a version of the IE driver that does not have it?
This is my first roll-out of Selenium. I have used CodedUI up to this point, and it has worked very well, but since Microsoft has announced it is discontinuing it I have been trying to bring the Selenium product online as a replacement. So far I have overcome most of the Selenium deficiencies to give myself back CodedUI like functionality, hopefully this is the last issue left.
Here is my basic call to start the driver:
/*
* Startup the correct Selenium browser driver.
*/
_Service = InternetExplorerDriverService.CreateDefaultService(seleniumPath);
var options = new InternetExplorerOptions()
{
// Mouse clicking takes a long time using NativeEvents, so trying turning it off
EnableNativeEvents = false
};
_Browser = new InternetExplorerDriver((InternetExplorerDriverService)_Service, options);
_Browser.Manage().Timeouts().PageLoad = new TimeSpan(0, 5, 0); // wait for 5 minutes
I have created some generic retry methods. This is a hack around a limitation in Selenium. Selenium has some built-in timeouts that can and should be used where appropriate, however not all calls to the drivers seem to honor those timeouts. Also, not all driver communication issues are a result of Selenium timing itself out after not hearing back; if the issue is due to network or permission issues then these methods will not help at all.
The main timeouts in Selenium for PageLoad, Script, and ImplicitWait should be used to fix timeout issues specific to those areas.
These methods (modified from another source) fix a very narrow set of issues where Selenium loses connection to the web driver part way through the call, or when it times out and you have no other way of extending the timeout period. They work by initiating a new call to the driver, in some instances this can result in the action being called multiple times in the browser, so use them with care.
/// <summary>
/// These retry methods are necessary because Selenium is incapable of handling timeouts
/// inside it's own system when it temporarily loses connection to the Driver.
/// Called like:
/// var return = RetryWebDriverServiceCall(f => object.method(param));
/// var return = RetryWebDriverServiceCall(f => object.attribute);
/// </summary>
/// <param name="serviceMethod"></param>
public delegate void VoidAction(params object[] oArgs);
public void RetryWebDriverServiceCall(VoidAction serviceMethod)
{
for (var loop = 0; loop < 3; loop++)
{
try
{
serviceMethod();
break;
}
catch (WebDriverException ex) // (WebDriverTimeoutException ex)
{
if (!ex.Message.Contains("timed out after 60 seconds") || loop >= 2)
throw new Exception($"UI Retry #: {loop}", ex);
System.Threading.Thread.Sleep(500);
}
}
}
public delegate T ParamsAction<T>(params object[] oArgs);
public T RetryWebDriverServiceCall<T>(ParamsAction<T> serviceMethod)
{
for (var loop = 0; loop < 3; loop++)
{
try
{
return serviceMethod();
}
catch (WebDriverException ex)
{
if (!ex.Message.Contains("timed out after 60 seconds") || loop >= 2)
throw new Exception($"UI Retry #: {loop}", ex);
}
}
throw new Exception("RetryWebDriverServiceCall failed");
}