3

I'm executing an automated test with Selenium ChromeDriver against a form on a web page. When I click the Submit button on the form, my WebDriver is losing connection to the browser/page/components, etc. Any subsequent action against the page objects or the browser results in timeouts because it no longer has a connection. It's as if the submit causes the underlying connection to break.

This is the error I get and it's a similar error no matter if I'm trying to click a page object, manipulate the browser, read any attributes, etc.

The HTTP request to the remote WebDriver server for URL:

http://localhost:5621/session/270f189e4b90085032409e475c3a3079/url timed out after 60 seconds.

additional information: at System.Net.HttpWebRequest.GetResponse()\r\n at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)

Is there a way to re-establish(refresh) a Selenium WebDriver connection or best option, to prevent the connection from getting broken? The web app developers state that they don't know of anything the app would be doing that would cause it.

There is nothing special about the code - same code I execute for 100s of tests. submitButton.Click(); where submitButton uses a css locator. Again, I'm unable to manipulate any page objects at all anymore, as if the browser was shut down even though it's still up and open.

code is a simple button click

driver.FindElement(By.Id("btnLogin")).Click();

s mac
  • 125
  • 1
  • 1
  • 9
  • 2
    There are a number of suggestions (some for Firefox, some for Chrome) following this question: https://stackoverflow.com/questions/22322596/selenium-error-the-http-request-to-the-remote-webdriver-timed-out-after-60-sec – Ruud Helderman Nov 26 '18 at 20:05
  • Update the question with your _code trials_ and error stack trace. – DebanjanB Nov 26 '18 at 20:15
  • @RuudHelderman thank you! I searched for a long time and saw a lot of questions but not that one. That one had what I was looking for - it was that I needed to do a .Submit() instead of .Click(). Crazy. If you submit that as an Answer, I'll accept it. – s mac Nov 26 '18 at 21:36
  • @smac Glad it helped! Please feel free to [self-answer](https://stackoverflow.com/help/self-answer); I am confident you are in a better position to explain the solution than I am. – Ruud Helderman Nov 26 '18 at 23:18

1 Answers1

0

In my case, my button's type was "submit", not button. I don't know the reason that it would make it appear that all connection was lost with the page and page objects, but the fix was to change the .Click() to .Submit().

change this line

driver.FindElement(By.Id("btnLogin")).Click();

to

driver.FindElement(By.Id("btnLogin")).Submit();

It seems like you should get a Selenium exception on the Click() rather than nothing being accessible but this made it execute properly.

s mac
  • 125
  • 1
  • 1
  • 9