我正在使用 Chromedriver 尝试查找以下元素:
<td class="section-menuoption"
onmouseover="this.className='section-menuoption-hilite';"
onmouseout="this.className='section-menuoption';" align="left"
onclick="self.jssDetails.location='products.php?xUser=kery&xRand=123';">
Scheduled Changes
</td>
在 Firefox 中使用 SeleniumIDE 时,我可以毫无问题地使用此选择器:
//*[contains(text(), 'Scheduled Changes')]
但是,当我尝试将此选择器与 Chromedriver 一起使用时,我收到“没有这样的元素”错误(通过 maven 运行)。我的 Chromedriver 代码如下所示:
WebElement box = driver.findElement(By.xpath("//*[contains(text(), 'Scheduled Changes')]"));
System.out.print(box.getText());
box.click();
我尝试了不同的引用策略、不同的 xpath(在 SeleniumIDE 中也能正确解析),但没有成功。我现在唯一能想到的就是改变我的 XPath 实现,但我什至不确定 Chromedriver 是否可行。
任何帮助将不胜感激。