Best practice to wait for a change with Selenium Webdriver?

前端 未结 5 2332
情话喂你
情话喂你 2021-02-13 02:08

After a click event I need to wait for an elements attribute to change before proceeding further (click event causes certain elements to move out of focus and certain others get

5条回答
  •  不知归路
    2021-02-13 02:48

    I suggest use org.openqa.selenium.support.ui.ExpectedConditions.attributeToBe(WebElement element, String attribute, String value).

    e.g.

    WebDriverWait wait = new WebDriverWait(driver, 5); // time out after 5 seconds
    someElement.click();
    wait.until(ExpectedConditions.attributeToBe(someElement, "sort-attribute", "ascending"));
    

    (docs)

提交回复
热议问题