lairtech
lairtech

Reputation: 2417

Selenium: How to wait for DOM change?

My test needs to wait for server push update to delete a row from a table. How can I tell Selenium to wait until a change to the table DOM has occurred?

Upvotes: 5

Views: 7037

Answers (1)

Nathan Merrill
Nathan Merrill

Reputation: 8386

There are two ways:

  1. You can either wait for an element to be present (or not present) using wait.until(ExpectedConditions.presenceOfElementSelectedBy(By.selector()))

  2. You can test if JQuery is finished on the page with ((Boolean)driver.executeScript("return jQuery.active == 0"))

Upvotes: 6

Related Questions