Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for a page to fully load in Selenium

Tags:

java

selenium

I am using selenium with Java. I want to wait for page to load fully before doing any action on that page.

I have tried the following method, but it is failing to work as expected.

public void waitForElementToBeVisible(final WebElement element) {

    WebDriverWait wait = new WebDriverWait(WebDriverFactory.getWebDriver(), WEBDRIVER_PAUSE_TIME);

    wait.until(ExpectedConditions.visibilityOf(element));
like image 284
user6939 Avatar asked Oct 22 '25 00:10

user6939


1 Answers

WebDriverWait inherits methods like wait until.

So something like

webDriverWait.until(ExpectedConditions.visibilityOfElementLocated( elementLocator)

should work. You can use ExpectedConditions, it would make things simpler. You can also use the method visibilityOfAllElements

like image 83
Atul Avatar answered Oct 24 '25 14:10

Atul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!