请建议xpath打印“Vor 16 Stunden”

时间:2015-11-05 09:07:17

标签: selenium webdriver

<tr id="$PCaseContentsPage$ppxResults$l1" class=" cellCont" pl_index="1">
  <td class="hiddenCell " style="height:24px;">
  <td>
  <td>
  <div class="oflowDivM">
    <nobr>
    <div title="16 Stunden, 20 Minuten, 10 seconds Vor." style="text-overflow:ellipsis;overflow:hidden;text-align:left;width:100%;white-space:nowrap;color: #DD0000; font-weight:bold;">
      Vor 16 Stunden
    </div>

我想使用Webdriver打印"Vor 16 Stunden"。以下不起作用

driver.findelement(By.xpath(".//*[@id='$PCaseContentsPage$ppxResults$l1']/td[3]/div/nobr/div")).getText();

1 个答案:

答案 0 :(得分:2)

你可以去找:

string xpath = "//tr[@id='$PCaseContentsPage$ppxResults$l1']//div[contains(@title, '16 Stunden')]"
string text = driver.findelement(By.xpath(xpath)).getText();