Reputation: 1379
Sometimes when running selenium, it displays a message similar to:
WARN - Invalid length: Content-Length=798242 written=8192
And then Selenium stops responding. The website under automation runs on ASP.NET, and served up via IIS.
How do I prevent Selenium from stopping due to whatever error this is?
Upvotes: 3
Views: 1368
Reputation: 9851
The issue that Selenium Server is complaining about is that the page that was requested included a Content-Length header of 798242 bytes but Selenium only received 8192 bytes of data. I've found that this usually happens when one of your web pages manually writes to the Response stream instead of using the ASP.NET lifecycle.
Look for code like this:
Response.ClearContent();
string data = GetSomeData();
Response.Write(data);
Response.Flush();
Response.Close();
You need to add a Content-Length header like this:
Response.AddHeader("Content-Length", data.Length.ToString());
So your code should look something like this:
Response.ClearContent();
string data = GetSomeData();
Response.AddHeader("Content-Length", data.Length.ToString());
Response.Write(data);
Response.Flush();
Response.Close();
Upvotes: 0
Reputation: 61424
URLs can be only so long. There are hard limits defined in the RFC. I suspect you're issuing a command that results in a URL that exceeds these limits. You need to debug your Selenium scripts and figure out what's causing the problem rather than suppressing this symptom.
Upvotes: 1