Hfr*_*rav 5 java xpath css-selectors selenium-webdriver java-stream
我有一个表格,其中每一行都有一个下载链接,其中包含(部分)自动生成的 id 元素。这样做的原因是实际的 href 元素始终是“#”,因此 id 将下载分开。
我需要在 td 中找到该 id 元素的名称。也就是说:我知道表格行有一个 id 元素,我知道名称的一部分,我需要得到确切的名称。
我一次访问每一行,所以我一次只需要查看一个 td。无需查看整个表格。
当我知道名称时,我很清楚如何查找元素。但是当我只知道类型时找到元素是另一回事。
...
<tr>
<td class="journalTable-journalPost"
<a class="htext-small" href="#" id="downloadJournalPost-345">Download</a>
</td>
</tr>
<tr>
<td class="journalTable-journalPost"
<a class="htext-small" href="#" id="downloadJournalPost-346">Download</a>
</td>
</tr>
...
Run Code Online (Sandbox Code Playgroud)
我在 webdriver 中找不到任何可以让我按类型查找元素的方法。
部分名称会起作用,因为 id 获得名称“downloadJournalPost-xxx”,其中只有 xxx 更改。但是链接文本是我能找到的唯一值,它可以让我搜索部分匹配。
编辑:更完整的标记。
<td class="journalTable-journalpost">
<span class="hb-tekst--sekundar">In <!----><est-ikon class="ng-star-inserted">
<div aria-hidden="true" class="hb-ikon hb-ikon--pil3-inn ">
<svg focusable="false">
<use xlink:href="#ikon-pil3-inn"></use>
</svg>
</div></est-ikon><!----></span>
<span class="hb-tekst--mellomTittel hb-avstandIngen"> Application and attachments</span>
<a class="hb-tekst--liten" href="#" id="lastNedJournalPost-2892">Download journal post</a>
</td>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
640 次 |
最近记录: |