Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I am using Selenium 2.20 WebDriver to create and manage a firefox browser with C#. To visit a page, I use the following code, setting the driver timeouts before visiting the URL:

driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); // Set implicit wait timeouts to 5 secs

driver.Manage().Timeouts().SetScriptTimeout(new TimeSpan(0, 0, 0, 5));  // Set script timeouts to 5 secs

driver.Navigate().GoToUrl(myUrl);   // Goto page url

The problem is that sometimes pages take forever to load, and it appears that the default timeout for a page to load using the selenium WebDriver is 30 seconds, which is too long. And i don't believe the timeouts i am setting apply to the loading of a page using the GoToUrl() method.

So I am trying to figure out how to set a timeout for a page to load, however, I cannot find any property or method that actually works. The default 30-second timeout also seems to apply to when I click an element.

Is there a way to set the page load timeout to a specific value so that when I call the GoToUrl() method it will only wait my specified time before continuing?

1 Answer

0 votes
by (62.9k points)

Look at the code below:

C# WebDriver API now contains the appropriate method.


If you wish to Learn Selenium visit this Selenium Webdriver Tutorial by Intellipaat.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s automation testing course!

Browse Categories