0

I am automating an internal website whose pages use many Angular-based lazy loading strategies. I frequently encounter pages where Chromedriver will "hang" and the Driver becomes completely unresponsive - every Selenium call I make to FindElement, Refresh(), Url, will all time out & not return anything.

To test the Driver when it is in this state, I run the following lines of code as an attempt to "diagnose":

var url = Driver.Url;
var anyElements = Driver.FindElements(By.XPath("//*"));
Driver.Navigate().Refresh();

All of these commands result in the same respective error:

OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:49799/session/6cdb197c3bcffde5bc5b0f03e5bbe6f6/elements timed out after 60 seconds. ----> System.Net.WebException : The operation has timed out

OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:49799/session/6cdb197c3bcffde5bc5b0f03e5bbe6f6/url timed out after 60 seconds. ----> System.Net.WebException : The operation has timed out

OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:49799/session/6cdb197c3bcffde5bc5b0f03e5bbe6f6/refresh timed out after 60 seconds. ----> System.Net.WebException : The operation has timed out

When the Driver gets into this state, I cannot even call Driver.Close() or Driver.Quit() which is a huge problem - these commands also time out.

If I manually click anywhere on the web page, suddenly the Driver becomes responsive again and starts working as expected. But purely letting the automated test run on its own (with no manual intervention) consistently results in Driver getting hung up & unresponsive.

I would expect something as simple as Driver.Url, no matter the content of the page, would always return something given how simple the command is, but Selenium is timing out even with this simple command.

I have tried setting the page load strategy to both Eager and None with no luck.

I believe my issue is similar to what is described here, but this question does not have an answer that works for me: Selenium WebDriver loses connection to web page

Does anyone have suggestions for what I can do to get my Driver responsive again? I can reproduce the behavior consistently but unfortunately I cannot share the website I am testing, as it is internal to my company. Any suggestions to further narrow down the issue are appreciated. I have never seen anything like this before.

CEH
  • 5,701
  • 2
  • 16
  • 40
  • 1
    This looks to be a timeout between the driver and the browser. Those look like wire protocol commands being sent to the browser. That could possibly be caused by a page infinitely loading... but hard to say. (If there is a script running on a webpage that is constantly polling/running, it'll cause all sorts of havoc.) Do you get any standard timeout exceptions when using .get()? Maybe also include your remote machine's setup... – pcalkins Oct 05 '20 at 20:09
  • I was hoping setting PageLoadStrategy to "None" would ignore the infinite loading, but the setting seems to make no difference. I don't think there is a C# binding specifically for .get(), but .navigte().goToUrl(url) is timing out in with the same standard error as above. – CEH Oct 05 '20 at 20:17
  • 1
    I'd check the remote machine for any drivers or browsers that may still be running. (Sometimes that happens when the driver/browser crash...) Then re-launch fresh to see if it helps. (Or just restart that machine.) When you go to this web site manually does it look like it's constantly loading? (The little wheel in the upper-left keeps spinning?) If so, that's probably causing the issue. Selenium can't get itself in there to do it's thing. It may not even shut-down things correctly because it looses it's "hook". – pcalkins Oct 05 '20 at 20:31
  • This is all running on my personal machine, I haven't been able to run remotely yet due to these issues - I always double check to make sure there are no stray chromedriver processes or chrome browsers running between tests. The page in question is not showing any spinner or indication that it is still loading. – CEH Oct 05 '20 at 20:43
  • @pcalkins Other pages on this website are not giving me this problem, but one particular page that is problematic is the SSO sign-in - lots of redirects happening, and sometimes the browser will get stuck redirecting between the SSO page & the website itself - this is definitely an issue with the website itself, but consistently reproduces the issue. The other page that consistently repro's issue is an Angular grid page - the grid does not load in every scenario, and in these cases, the driver will lose connection to the browser. – CEH Oct 05 '20 at 20:45
  • I understand a lot of these issues are specific to the site that I am testing, but I'd at least like a way to cleanly fail the test & clean up the Driver. Because the driver-browser connection is lost, I cannot even perform proper test cleanup in these scenarios. – CEH Oct 05 '20 at 20:46
  • Not sure if this helps you, but when this happens you should still be able to use basic driver commands like .get(). I don't think those communicate via the wire protocol. If you try/catch all your calls you can set your fails in the catches... when quitting the driver, maybe use a get to something like google first... maybe that'll make things cleaner. – pcalkins Oct 05 '20 at 21:26
  • I'll try to find the C# binding for .get() or see if there's a way I can get some way to debug whatever is going on in the wire protocol. I appreciate the insight! – CEH Oct 05 '20 at 21:58
  • Also be sure the driver isn't getting stuck in no-mans land. For instance, if the SSO sign-in or the grid is in a frame/iframe that you switch the driver to, but that is removed from the page before switching the driver back to a context that exists... – pcalkins Oct 05 '20 at 22:13

0 Answers0