0
我一直在努力从Table中获取文本。当我检查萤火虫时,我可以从xpath获取值,但是当我运行代码时不会获取该值。 表中所示如下─尽管可以在DOM中搜索,但Selenium/C#Xpath无法正常工作
div class="description__table-holder">
<table class="description__table">
<tbody>
<tr>
<td>Test: </td>
<td>9780238905</td>
<td>Pas: </td>
<td>600</td>
</tr>
<tr>
<td>Size: </td>
<td>216 x 274mm</td>
<td> Result: </td>
<td> 9 To 12 </td>
</tr>
</tbody>
</table>
</div>
我曾尝试以下Xpaths-
html/body/div[2]/div[5]/div[2]/div/article/section[1]/section[2]/div[4]/div[1]/article/div/table/tbody/tr[1]/td[1]
html/body/div[2]/div[5]/div[2]/div/article/section[1]/section[2]/div[4]//table[@class='description__table']/tbody/tr[1]
html/body/div[2]/div[5]/div[2]/div/article/section[1]/section[2]/div[4]/div[1]/article/div/table/tbody/tr[1]/td/following-sibling::td[3]
但是,当我试图让硒/ C#值/ phantomJS司机我can't.Below is my code-
var datanew = driver.FindElements(By.XPath("html/body/div[2]/div[5]/div[2]/div/article/section[1]/section[2]/div[4]//table[@class='description__table']/tbody/tr[1]"));
var other = "";
ArrayList others = new ArrayList();
foreach (var dat in datanew)
{
//var linkDriver = new FirefoxDriver();
other = dat.Text;
others.Add(other);
}
string test = driver.FindElement(By.XPath("html/body/div[2]/div[5]/div[2]/div/article/section[1]/section[2]/div[4]/div[1]/article/div/table/tbody/tr[1]/td/following-sibling::td[3]")).Text;
嗨,我已经尝试了隐式和显式等待,但它不起作用。虽然尝试过这在Java中,它工作得很好。 –
如果上述解决方案运行良好,那么您可以将此答案标记为正确,以便对其他方面有用。 –
它不起作用。 –