3

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)); 
2

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>));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.