<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height="100%" vAlign=top width="86%" align=center>
<TABLE cellSpacing=0 cellPadding=0 width="80%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=center>
<TABLE class=table_border_dark cellSpacing=1 cellPadding=0 width="80%" border=0>
<TBODY>
<TR align=center>
<TD bgColor=#ffffff colSpan=2>
<TABLE class=table_border_dark cellSpacing=1 cellPadding=1 width="60%" border=0>
<TBODY><LEGEND><B>Successfully Completed</B></LEGEND></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
我尝试过:
boolean table = driver.findElement(By.xpath("//div[@id='eodProgress']/..//b[contains(text(),'EOD Process Successfully Completed')]")).isDisplayed();
System.out.println(table);
但我收到一个错误,它无法找到该元素。
要在<b>
标记中提取文本,即成功完成,您必须为visibilityOfElementLocated引入WebDriverWait,并且您可以使用以下任一解决方案:
cssSelector
:
String myText = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("TABLE.table_border_dark LEGEND>B"))).getAttribute("innerHTML");
xpath
:
String myText = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//TABLE[@class='table_border_dark']//LEGEND/B"))).getAttribute("innerHTML");