In my webdriver
test, I have the below. Despite the SetPageLoadTimeout
, the script is still executing the next line before allowing the page to load.
driver.FindElement(By.LinkText("MySurvey")).Click(); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(120));
1 Answer 1
SetPageLoadTimeout
is saying how long you want to wait for the page to load before the test fails.
What you're after is waiting for an element to appear:
WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id<locator>));
or
wait.until(ExpectedConditions.elementToBeClickable(By.id<locator>));
answered Jun 14, 2016 at 19:27
default