【发布时间】:2016-02-15 19:29:14
【问题描述】:
我正在尝试设置一个 WebElement,以便我可以点击它:
executor.executeScript("arguments[0].click();", WebElement);
但是当我尝试查找元素时,它只是不断抛出无法定位元素,我尝试了几种方法,但它不会找到它。
这是元素的 HTML 路径 (td#tab_6)
<table id ="menuHolderTable" class="menuGolderTable">
<tbody>
<tr>
<td id="MenuGolderCell" class="MenuHolderCell">
<table id="MenuTable"class="MenuTable">
<tbody>
<tr>
<td id="tab_6" class="tab_6">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
这是我的代码:
wait.until(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[contains(text(),'Loading...')]"))));
WebElement toolTab = driver.findElement(By.xpath("//table[@id='MenuTable']/tbody/tr/td"));
这是错误:
线程 "main" org.openqa.selenium.NoSuchElementException 中的异常:无法找到元素:
{"method":"xpath","selector":"//table[id='MenuTable']/ tbody/tr/td"}
命令持续时间或超时:36 毫秒
有关此错误的文档,请访问:
http://seleniumhq.org/exceptions/no_such_element.html
【问题讨论】:
-
我在这里找到了这个问题的答案:stackoverflow.com/questions/24145364/… 问题不是切换帧。