我正在使用Selenium测试一个网页,有时它会变得不可靠,因为它仍在处理"Vue“,并且代码开始在屏幕上查找元素。但我应该等到vue完成加载。
我怎么能等到Vue完成处理?
例如,当它加载时,我可以看到vue标签:
发布于 2018-07-04 21:20:25
也许像这样的方法值得一试,通过定制vue标签不存在的预期条件:
protected void waitForTagNonExistence(WebElement element) {
WebDriverWait wait = new WebDriverWait(getDriver(), ELEMENT_WAIT_TIMEOUT_SECONDS);
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
try {
return (element.getAttribute("v-touch:tap") == null);
} catch (NullPointerException nullPointerException) {
return false;
}
}
});
}
发布于 2018-07-04 21:20:32
可以将wait
函数与以下xPath
一起使用
driver.wait(until.elementIsClickable(By.xpath("//img[not(@v-on:click = 'drop') and @src = 'img/end_call.svg']")), 15000);
xPath使用not
和and
。not
表示将选择没有@v-on:click = 'drop'
属性的元素。and
将使用@src = 'img/end_call.svg'
而不是@v-on:click = 'drop'
来选择元素
有关xPath
运算符的更多信息,请访问here。
https://stackoverflow.com/questions/51180410
复制相似问题