-1

以下是我寻找的元素的萤火虫片段。该元素位于表格中的单元格上,其中许多将具有相同的状态,所以我不能只检查“正在运行”的页面源

<td>
<td id="name3" scope="row">
<td id="machineName3">Machine-0</td>
<td id="state3">RUNNING</td>
<td id="transitionActivity3">
</tr>

“RUNNING”变成了许多不同的东西。Firebug 为该元素建议的 xpath 是

//*[@id="state3"]

但是,如果我正确理解了这个 xpath 的东西,只会检查元素是否存在,而不是它包含我正在寻找的状态。在这个例子中我将如何检查运行?

4

1 回答 1

1

使用 Selenium 的 WebDriver 类,您可以使用以下代码检查该值:

    WebElement state3Cell = driver.findElement(By.id("state3"));
    assertEquals("RUNNING", state3Cell.getText());
于 2013-04-29T14:56:11.783 回答