Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium ChromeDriver manage timeout

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

like image 240
Maki92 Avatar asked Dec 11 '25 19:12

Maki92


1 Answers

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.

like image 144
Athanasios Kataras Avatar answered Dec 14 '25 16:12

Athanasios Kataras