我正在尝试使用以下代码等待点击之后更改图标(通过尝试比较图标的src值) -
(new WebDriverWait(getFlowContext().getWebDriver(), 180)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
WebElement iconToClick = null;
List<WebElement> elementList = getFlowContext().getWebDriver().findElements(
By.xpath("//*[starts-with(@data-uxf-point, 'node')]"));
for (WebElement webElement : elementList) {
if (webElement.getAttribute("data-uxf-point").contains("abc")) {
iconToClick = webElement;
break;
}
}
String text1 = iconToClick.findElement(By.xpath(".//*[@data-uxf-point='icon']")).getAttribute("src");
int len = text1.length();
String text2= text1.substring(len - 23, len);
System.out.println("test:"+text2);
return text2.equals("images/not-feasible.png");
}
});
当我手动执行此操作时,图标确实会发生变化(几秒钟后)。但是在尝试通过硒自动化时,即使在等待180秒后我也没有得到预期的图标。点击后我也尝试了下面的代码 -
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我哪里错了?