Reputation: 441
ChromeOptions options = new ChromeOptions();
options.PageLoadStrategy = PageLoadStrategy.Eager;
string[] options_list = new string[]
{
"start-maximized",
"enable-automation",
//"--headless",
"--no-sandbox",
"--disable-infobars",
"--disable-dev-shm-usage",
"--disable-gpu",
"enable-features=NetworkServiceInProcess"
};
options.AddArguments(options_list);
using (IWebDriver driver = new ChromeDriver(options))
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(5));
driver.Navigate().GoToUrl(url);
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Name("lgin"))).Click();
// After lgin clicked
// Page may load for 3 to 5 minutes due to huge data processing
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("Img2"))).Click();
}
During the 3 to 5 minutes wait, I will always hit the exception error below.
The HTTP request to the remote WebDriver server for URL http://localhost:50696/session/b8dbc3609bdb0d779c81886942342b6d/element/1fc37ce8-a8a0-4a51-84ed-18828edf7b46/click timed out after 60 seconds.
I tried to add the codes below:
driver.Manage().Timeouts().PageLoad.Add(TimeSpan.FromMinutes(5));
driver.Manage().Timeouts().ImplicitWait.Add(TimeSpan.FromMinutes(5));
But the timed out times still 60 seconds
Upvotes: 3
Views: 4612
Reputation: 672
try this code
using (IWebDriver driver = new
ChromeDriver(options))
{
Thread.Sleep(8000); // or higher
driver.Navigate().GoToUrl(url);
driver.FindElement(By.Name("lgin")).Click();
// Thread.Sleep(8000); // or higher
// try this upper line if you need it
driver.FindElement(By.Id("Img2")).Click();
}
Upvotes: 0
Reputation: 26450
Have you tried with WebDriverWait
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
It's quite probable that you've hit this issue: https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4874
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.
Upvotes: 3