Как извлечь динамический текст внутри <nobr>, используя селен вебдрайвер? - PullRequest
0 голосов
/ 25 января 2019

Я пытаюсь получить имя файла сервера в текстовом формате в DOM внутри тега <nobr>, и я получаю сообщение об ошибке.

Ошибка

Invokemethod error(source not found)
Need the text to be stored in string using selenium webdriver- "/services/aps/load_files/upload/WireTransfer_BatchImport_CForeignUSD_155342006955_201901250134.csv"

HTML-код

<table id="innerTable" class="summaryTable" cellspacing="0" 
  cellpadding="0" style="">
  <tbody>
    <tr
       onclick="updateOID('155341609897','E_IMPORT_FILE_UPLOADED');
       onRowClick();" 
       rowvalues="155341609897E_IMPORT_FILE_UPLOADED" 
       class="summaryRow_Even">
      <td class="summaryCell" nowrap="" style="width: 275px;">
        <nobr 
           style="width:275px;">
             WireTransfer_BatchImport_CForeignUSD.csv&nbsp; 
        </nobr>
      </td>
      <td class="summaryCell" nowrap="" style="width: 631px;">
         <nobr 
            style="width:631px;">
            /services/aps/load_files/upload/WireTransfer_BatchIm 
            port_CForeignUSD_155342006955_201901250134.csv&nbsp; 
         </nobr>
      </td>

Что я пробовал до сих пор

String text = getDriver().findElement(By.xpath("//*[@id='innerTable']/tbody/tr[1]/td[2]/nobr/text()")).getText();
String text = getDriver().findElement(By.xpath("//*[@id='innerTable']/tbody/tr[1]/td[2]/nobr/text()")).getAttribute("innerHTML");

Также пробовал,

String text = getDriver().findElement(By.xpath("//nobr[contains(text(),'/services/aps/load_files/upload/WireTransfer_BatchImport_CForeignUSD')]")).getAttribute("innerHTML");

1 Ответ

0 голосов
/ 25 января 2019

Надеюсь, это сработает // nobr [содержит (text (), '/ aps')]

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...