Quality Testing

Quality is delighting customers

Interview Question: When will use WebDriverWait in Selenium?

Please explain with scenario?

Views: 70

Reply to This

Replies to This Discussion

This is the most common question that is asked by any quality assurance company when hiring automation engineers.

We can use webdriverwait when we want to wait until a particular condition is met or the specified time is elapsed. This wait works for a particular instance only & also can throw exceptions when element not found.

Syntax:
//WebDriverWait wait = new WebDriverWait(WebDriverRefrence,TimeOut);

For e.g:
WebDriverWait wait = new WebDriverWait (driver, 20);
wait.until(ExpectedConditions.VisibilityofElementLocated(By.xpath(""//button[@value='Submit']"")));

However, You can provide more details about this wait like expected condition etc.

WebDriverWait uses the below mentioned expected conditions:

alertIsPresent()
elementSelectionStateToBe()
elementToBeClickable()
elementToBeSelected()
frameToBeAvaliableAndSwitchToIt()
invisibilityOfTheElementLocated()
invisibilityOfElementWithText()
presenceOfAllElementsLocatedBy()
presenceOfElementLocated()
textToBePresentInElement()
textToBePresentInElementLocated()
textToBePresentInElementValue()
titleIs()
titleContains()
visibilityOf()
visibilityOfAllElements()
visibilityOfAllElementsLocatedBy()
visibilityOfElementLocated()

I hope this resolves your query.

Thanks
Anand Singh

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service