【发布时间】:2019-06-22 12:44:59
【问题描述】:
我正在尝试对元素属性执行 wait.until,如下所示...
public static void WaitForElementSize(WebElement element, WebDriver driver, int timeoutInSeconds)
{
if (timeoutInSeconds > 0)
{
System.out.print(element.getAttribute("style"));
WebDriverWait wait = new WebDriverWait(driver, timeoutInSeconds);
wait.until(ExpectedConditions.attributeToBe(element, "style", "top: 0px;"));
}
}
我从打印行知道该属性符合预期,即“top: 0px;”但是当我单步执行wait.until 上的代码时,UI 中的元素被“单击”并更改为关闭(在这种情况下,样式更改为“top: 120px;”)。然后该方法从头开始,然后失败,因为它现在是错误的。
任何关于为什么方法重新运行和更改值的帮助将不胜感激。
我也试过了……
wait.until(e -> element.getAttribute("style") == "top: 0px;");
但这因其他原因而失败,因此尝试了替代方案。
【问题讨论】:
-
你的代码中UI中的元素在哪里被“点击”?
标签: java eclipse selenium expected-condition