Skip to main content
Add code callout
Source Link
Kate Paulk
  • 31.5k
  • 8
  • 55
  • 109

Does anything change on the page when the file has loaded? If it does then explicitly wait for that change to occur. I've got a packaged method in my common library that I employ in these situations (packaged so I don't need to write the entire code each time) with a default timeout set to a value that I'd reasonably expect the action to be completed within E.g: public static IWebElement WaitForElementToAppearOnPage(this WebSiteBase unitTest, IWebElement element, double timeout = 30.00) { var wait = new WebDriverWait(unitTest.Selenium, TimeSpan.FromSeconds(timeout)); return wait.Until(driver => element); }

public static IWebElement WaitForElementToAppearOnPage(this WebSiteBase unitTest, IWebElement element, double timeout = 30.00)
        {
            var wait = new WebDriverWait(unitTest.Selenium, TimeSpan.FromSeconds(timeout));
            return wait.Until(driver => element);
        }

I use similar methods to wait for the page to load or for ajax calls to complete.

Does anything change on the page when the file has loaded? If it does then explicitly wait for that change to occur. I've got a packaged method in my common library that I employ in these situations (packaged so I don't need to write the entire code each time) with a default timeout set to a value that I'd reasonably expect the action to be completed within E.g: public static IWebElement WaitForElementToAppearOnPage(this WebSiteBase unitTest, IWebElement element, double timeout = 30.00) { var wait = new WebDriverWait(unitTest.Selenium, TimeSpan.FromSeconds(timeout)); return wait.Until(driver => element); }

I use similar methods to wait for the page to load or for ajax calls to complete.

Does anything change on the page when the file has loaded? If it does then explicitly wait for that change to occur. I've got a packaged method in my common library that I employ in these situations (packaged so I don't need to write the entire code each time) with a default timeout set to a value that I'd reasonably expect the action to be completed within E.g:

public static IWebElement WaitForElementToAppearOnPage(this WebSiteBase unitTest, IWebElement element, double timeout = 30.00)
        {
            var wait = new WebDriverWait(unitTest.Selenium, TimeSpan.FromSeconds(timeout));
            return wait.Until(driver => element);
        }

I use similar methods to wait for the page to load or for ajax calls to complete.

Source Link
Chrissi
  • 111
  • 2

Does anything change on the page when the file has loaded? If it does then explicitly wait for that change to occur. I've got a packaged method in my common library that I employ in these situations (packaged so I don't need to write the entire code each time) with a default timeout set to a value that I'd reasonably expect the action to be completed within E.g: public static IWebElement WaitForElementToAppearOnPage(this WebSiteBase unitTest, IWebElement element, double timeout = 30.00) { var wait = new WebDriverWait(unitTest.Selenium, TimeSpan.FromSeconds(timeout)); return wait.Until(driver => element); }

I use similar methods to wait for the page to load or for ajax calls to complete.