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)); 
Rao
2264 silver badges12 bronze badges
asked Jun 14, 2016 at 19:08

1 Answer 1

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>));
answered Jun 14, 2016 at 19:27
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.