如何等待一个CSS属性改变?(How to wait for a css attribute to change?)

我如何告诉Selenium webdriver等待特定的元素在css中设置特定的属性?

我想等待: element.getCssValue("display").equalsIgnoreCase("block")

通常情况下,等待元素如下所示: webdriver.wait().until(ExpectedConditions.presenceOfElementLocated(By.id("some_input")));

我如何等待display属性的特定CSS值?

How can I tell Selenium webdriver to wait on a specific element to have a specific attribute set in css?

I want to wait for: element.getCssValue("display").equalsIgnoreCase("block")

Usually one waits for elements to be present like this: webdriver.wait().until(ExpectedConditions.presenceOfElementLocated(By.id("some_input")));

How can I wait for the specific css value of display attribute?

最满意答案

我认为这会对你有用。

webdriver.wait().until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='some_input'][contains(@style, 'display: block')]")));

I think this would work for you.

webdriver.wait().until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='some_input'][contains(@style, 'display: block')]")));

更多推荐