[英]How to extract the dynamic text inside <nobr> using selenium webdriver?
我正在嘗試在<nobr>
標記內獲取 DOM 中文本格式的服務器文件名,但出現調用程序錯誤。
錯誤
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
</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
</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");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.