0

I have a problem when running the test cases because the time take for loading the page is different in each time. I have tried WaitforPageLoad and also checking for visual elements but it was not helping.

WaitforPageLoad always wait for specific seconds and checking visual elements wont work all the time since after loading the page there won't be any new elements in some pages.

Could anyone suggest a better idea ?

Aj Matthew
  • 11
  • 3

2 Answers2

0

You could increase the amount of time you wait for a page load:

setTimeout(timeout) Arguments:

    timeout - a timeout in milliseconds, after which the action will return with an error

Specifies the amount of time that Selenium will wait for actions to complete.

Actions that require waiting include "open" and the "waitFor*" actions.
The default timeout is 30 seconds.

This might help. It's a bit unclear what your goal is.

DMart
  • 2,401
  • 1
  • 14
  • 19
0

Use the Explicit Wait on your action. For instance:

            // Tell webdriver to wait
            WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(4));

            // Test the autocomplete response - Explicit Wait
            IWebElement autocomplete = wait.Until(x => x.FindElement(By.ClassName("ac-row-110457")));