Reputation: 1142
I have an automated task that runs for a long time. Sometimes, it takes over a minute for the webpage to fully load so I have tried to set the default timeout in two different ways. Both do not work, I still get that default timeout after 60 seconds error.
public IWebDriver driver;
public DataAuditsUtility()
{
driver = new ChromeDriver();
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(180);
}
I have also tried like this...
public IWebDriver driver;
public ChromeOptions options;
public DataAuditsUtility()
{
options = new ChromeOptions();
options.AddArgument("--no-sandbox");
driver = new ChromeDriver(options);
}
From what I have seen, both of these should work.. I am starting to think it may be an issue with how I am instantiating the chrome driver. What I do, is I have a class DataAuditsUtility, that has its own instance of WebDriver and I instantiate it and set it up in the constructor. This class has a bunch of methods that make actions on the page.
In the test class, I instantiate this class and just call its methods. The automation runs great however the only issue is I can not figure out how to increase the URL timeout. Any ideas as to why the above does not work? Thanks!
Also worth nothing in this solution that I do not have a config file anywhere. We actually do not use selenium in the solution other than this one test class so I would like to contain all configurations in here rather than a config file elsewhere.
Upvotes: 0
Views: 3723
Reputation: 603
There was an issue reported where webdriver timed-out at a maximum of 60 seconds.
here is a quote from that:
Each driver class has a constructor overload that allows you to set the timeout for each command. Here is an example for the FirefoxDriver to set the command timeout to 5 minutes:
IWebDriver driver = new FirefoxDriver(new FirefoxBinary(), null, TimeSpan.FromMinutes(5));
You can find similar constructor overloads for InternetExplorerDriver, ChromeDriver, and RemoteWebDriver.
and
When using these constructors it appears that the WebDriverWait is overridden.
IWebDriver driver = new FirefoxDriver(new FirefoxBinary(), null, TimeSpan.FromHours(2));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(2)); ...
This caused it to wait for 2 hours rather than two minutes.
So it appears you can set a value on instantiation.
Upvotes: 2