我正在Selenium
使用Java
.
有很多divisions (divs)
相同class
但spans
attributes
不同的...
示例 HTML:
<div class="message_bubble">
<span data-icon="ready_to_send" class="">
.....
.....
</span>
</div>
// another div with same class="message_bubble"
<div class="message_bubble">
<span data-icon="sent" class="">
.....
.....
</span>
</div>
// again div with same class="message_bubble"
<div class="message_bubble">
<span data-icon="received" class="">
.....
.....
</span>
</div>
// There are many divs as such
当ready_to_send
被发送到服务器时,它的跨度attribute
变为sent
.
如何让驱动程序等到没有具有 span 属性ready_to_send
的部门,或者换句话说,所有部门都具有 span attribute
sent
。
我的非工作代码是:
private Boolean GetStatus()
{
WebDriverWait UntilSent = new WebDriverWait(driver, 10);
Boolean Status;
Status = UntilSent.until(new ExpectedCondition<Boolean>()
{
public Boolean apply(WebDriver driver)
{
//int elementCount = driver.findElements(By.xpath("//span[@data-icon='ready_to_send']")).size();
int elementCount = driver.findElements(By.xpath("//div[@class='message_bubble']/span[@data-icon='ready_to_send']")).size();
System.out.println("UNSENT count is.... : "+elementCount);
if (elementCount == 0)
return true;
else
return false;
}
});
return Status;
}