【发布时间】:2017-09-02 07:38:34
【问题描述】:
以下是 HTML 中的代码
<div id="pMenu_root_10" class="itemBorder" style="position: absolute; left: 809px; top: 0px; width: 58px; height: 98px; z-index: 1000; background: rgb(190, 213, 231) none repeat scroll 0% 0%; cursor: default;" onmouseover="pMenu.over('root',10)" onmouseout="pMenu.out('root',10)" onclick="pMenu.click('root',10)">
<div class="lowText" style="font-size: 11px; FONT-FAMILY: Arial; color: #0066CC; position: absolute; left: 1px; top: 1px; width: 56px; height: 96px">Reports</div>
</div>
我正在尝试将鼠标从 selenium 悬停到,以便我可以选择存在的子菜单之一。但是我的硒无法获取元素
WebElement ele = driver.findElement(By.xpath(".//div[@id='pMenu_root_10']/div[text()='Reports']"));
Actions act = new Actions(driver);
act.moveToElement(ele).perform();
我尝试使用 Firepath 提供的绝对 Xpath
.//*@id='loginFormName']/table[2]/tbody/tr/td[2]/table[1]/tbody/tr[5]/td/div/table/tbody/tr/td[3]/img
请帮我找出问题
下面是返回的错误
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":".//div[@id='pMenu_root_10']/div[text()='Reports']"}
【问题讨论】:
-
仍然报同样的错误。它仍然没有得到 pMenu_root_10
-
请传递错误,您能分享您的网站网址吗?
-
这是公司网站,有登录凭证,所以不能分享。如果你愿意,我可以在线程“main”org.openqa.selenium.NoSuchElementException 中传递 html 代码异常:没有这样的元素:无法找到元素:{“method”:“xpath”,“selector”:“。//* [@id='pMenu_root_10']/div"}
-
请注意,当我尝试通过 ff 中的 xpath 搜索标签时,我能够找到这个元素