MgSam MgSam - 1 year ago 95
C# Question

Selenium timeout on ExecuteScript

I'm getting timeouts when executing scripts with Selenium no matter what I try and do to avoid them.

I first set the timeouts to something ridiculously long:


Later, I run a script which is expected to take a long time (it's doing a long running POST request). No mater whether I use
, the request times out at 60 seconds.

Is there anything I can do to avoid this? Even a hack or workaround would be good at this point.

Answer Source

Your favorite RemoteWebDriver (FireFoxDriver or ChromeDriver) takes a commandTimeout parameter in some of its constructor overloads.

_driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), new ChromeOptions(), TimeSpan.FromMinutes(30))

There appears to be no way to change this after the instance is constructed, so you need to make sure to set it this way. This will prevent the timeouts.