How to set Page Load Timeout using C using Selenium WebDriver

0 votes

I want 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.

How to avoid this problem?

Aug 2, 2018 in Selenium by Martin
• 4,320 points
10,126 views

The solution for C#. Hope, it`ll help somebody.

   driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);  //time to wait untill page is loaded
   try
   {
      driver.Navigate().GoToUrl(url);  //if page is not loaded in 10 sec exception is thrown
   }
   catch
   {
      //catch timeout exception
   }

3 answers to this question.

0 votes

C# WebDriver API now contains the appropriate method.

driver.Manage().Timeouts().SetPageLoadTimeout(timespan)

answered Aug 2, 2018 by Samarpit
• 5,910 points
This does not work
+1 vote
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(15);
answered Apr 17, 2019 by Tim Muir
0 votes

Try to use 

driver.get("url");
answered Sep 6, 2020 by Sri
• 3,190 points

Related Questions In Selenium

0 votes
1 answer

How to set Page Load Timeout using C# and Selenium Webdriver

Check this out C# WebDriver API now contains ...READ MORE

answered Aug 3, 2018 in Selenium by Samarpit
• 5,910 points
6,252 views
0 votes
2 answers

How to know the exact time to load a page using Selenium WebDriver?

long start = System.currentTimeMillis(); driver.get("Some url"); long finish = ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
8,033 views
0 votes
2 answers

How to get a page name using Selenium Webdriver (C#)?

String pageTitlte=driver.getTitle(); READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
2,620 views
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,922 views
0 votes
1 answer

How to control Chrome Downloads page Using Selenium c#?

In your case you must replace 'cancel' ...READ MORE

answered May 7, 2018 in Selenium by Samarpit
• 5,910 points
9,757 views
0 votes
2 answers

How to open a browser window in full screen using Selenium WebDriver with C#

Hi , we have inbuilt method Maximize(). driver.Manage().Wind ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
16,039 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,684 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,148 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,226 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,879 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP