We have a number of Selenium tests running 24/7 and a few times a day we are getting random
webdriver timeout exception. For example:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://*.*.*.*:4444/wd/hub/session/4957b6a8-c885-4dd7-98ab-373f35619495/url timed out after 120 seconds. ---> System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.get_Url()
...
Usually it happens in random places (when fetching the current URL, when clicking an element, finding an element, etc.) and in different tests.
RemoteWebDriver's command timeout for HTTP requests is set to 120s and none of the timeouts set with Manage().Timeouts().* exceed 60 seconds.
My question is, what could be the possible reasons for the command timeout?
It looks like Selenium or possibly the ChromeDriver just locks occasionally for whatever reason. Although I am unable to verify anything visually since the tests are executed on a headless machine.
Could it be that we overlooked or misunderstood some timeout setting?
Versions:
Selenium v2.42.2, .NET bindings v2.40.0, ChromeDriver 2.10
Related
I am moving from selenium 3 to 4 and trying to run my tests in edge-IE mode. After starting the IEDriver with
var driver = new InternetExplorerDriver(ieOptions);
the browser opens but then does not hand control back the the code for the next step, instead I get a time out error.
here is my code.
var options = new InternetExplorerOptions();
options.AttachToEdgeChrome = true;
options.EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
//options.BrowserCommandLineArguments = "-private";
IWebDriver edgeIeMode = new InternetExplorerDriver(options);
here is the error
Unhandled Exception, See screenshotOpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:63459/session/197d3eaa-361d-433e-b8b5-0b5d6acb1e7b/url timed out after 60 seconds. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at OpenQA.Selenium.Remote.HttpCommandExecutor.d__35.MoveNext()
Verify that your edge and webdriver versions are up to date. Typically this happens when a version mismatch can't connect to the browser. I'm not sure if edge uses an IEdriver.exe executable, but if it does, verify that version too.
For some context, I have a Windows Scheduled Task set-up running as the SYSTEM user, which periodically opens a small Console Application which makes use of Selenium and specifically the IE Driver. This works perfectly well for a long period of time, but after a month or two has passed it eventually begins failing every time the scheduled task executes with the error below.
The only solution I have found is to restart the application server, whereby the issue is resolved for another month or two, until it magically reappears.
I have taken a look at other Stack Overflow questions of a similar nature, but their solutions haven't allowed this to be resolved. The questions also don't appear to run Selenium as a Scheduled Task as the SYSTEM user so I feel this is a unique take on the issue?
Does anyone have any advice as to what might be causing this issue to reappear? I am looking to avoid having to restart the server as this has to be scheduled in, resulting in a number of days with my Scheduled Task being in the disabled state causing me to less aware of my application isn't working.
Message: The HTTP request to the remote WebDriver server for URL http://localhost:57185/session timed out after 240 seconds.
InnerException: System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
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.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(String internetExplorerDriverServerDirectory, InternetExplorerOptions options, TimeSpan commandTimeout)
I have a set of Selenium tests in a test project within my solution, and they run just fine from within Visual Studio. However, when I check in code and they run as part of my continuous integration build profile, they fail.
A brief explanation of the setup:
1) Code is checked into the build agent server.
2) The project is then built, and then deployed to server 2 (which is remote from the build server).
3) Unit tests then run.
Here is an example unit test:
public void Login_InvalidAccessUrl_ShowMesage()
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
driver.Navigate().GoToUrl("https://testsite.company.com/Login");
IWebElement el = driver.FindElementById("invalidAccessUrlSection");
Assert.AreNotEqual(el, null);
}
This runs beautifully from Visual Studio, but when CI runs the same tests, I get the following:
Error Message:
Test method eNotify.Staff.Tests.SeleniumTests.Login_InvalidAccessUrl_ShowMesage threw exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:11570/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
TestCleanup method eNotify.Staff.Tests.SeleniumTests.Dispose threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
Stack Trace:
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--- End of inner exception stack trace ---
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)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor()
at eNotify.Staff.Tests.SeleniumTests.Login_InvalidAccessUrl_ShowMesage()
TestCleanup Stack Trace
at eNotify.Staff.Tests.SeleniumTests.Dispose()
Am I missing a driver or some software? As far as I know, there is nothing listening on port 11570.
First, make sure the VSTS agent is running as Interactive process.
Secondly, adding no-sanbox argument to ChromeDrive instance. For example:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("no-sandbox");
driver = new ChromeDriver(chromeOptions);
I use phantomjs with slow proxy. I use resourceTimeout to force phantomjs to wait for resources downloading and not to fail.
I set resourceTimeout = 120000 (2 minutes). However, phantomjs throws onResourceError after some seconds of waiting for proxy (I am 100% sure proxy doesn't interrupt connection, phantomjs does it).
So, if phantomjs throws onResourceError much faster that timeout may appear, the question is: does resourceTimeout actually work and what does this setting mean?
I'm using Selenium 2.20 . Why does WebDriver InternetExplorerDriver throw this warning when launching browser? This is happening to me during a parameterized JUnit test. The warning is thrown each time I am invoking "new InternetExplorerDriver()" . After it retries, it succeeds on the second attempt of whatever it is doing. So, in other words, the tryExecute call has to run twice before my IE instance works in WebDriver.
org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request:
Software caused connection abort: recv failed
org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
This is a warning message. The native code (C++) component of the IE driver includes an HTTP server, since the driver uses the JSON Wire Protocol for its communications. That HTTP server takes a small amount of time to start and be ready to receive HTTP requests. However, the RemoteWebDriver's HTTP client (remember that InternetExplorerDriver is a subclass of RemoteWebDriver) cannot know exactly when that server is available, so this causes a race condition. The HTTP client must poll the server until it receives a valid response. When you're seeing this warning, it's only telling you that the internal HTTP server hasn't completed its initialization, and the HTTP client has lost the race. It should be harmless, and you should be able to safely ignore it.
Since this message is not going to be important for most cases as it is a known race condition, you can configure java.util.logging to ignore it by passing in a custom log configuration using this Java code:
LogManager.getLogManager().readConfiguration(
getClass().getResourceAsStream(
"/META-INF/logger.properties"));
And a file META-INF/logger.properties
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
org.apache.http.impl.client.DefaultHttpClient.level=WARNING