导航树中的Selenium问题

时间:2016-05-04 02:34:36

标签: java selenium

我目前面临着扩展导航树的一些问题。在回放期间,selenium驱动程序将单击父树节点,但无法展开树映射并找到子节点。然后Eclipse将抛出异常 -

  

org.openqa.selenium.ElementNotVisibleException:未显示元素(警告:服务器未提供任何堆栈跟踪信息)。

尝试使用等待(WebElement element = (new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(By.id("itemTextLink5")));),但似乎无法找到特定元素。因此,它会抛出超时异常 -

  

org.openqa.selenium.TimeoutException:等待元素可点击10秒后超时:

driver.findElement(By.linkText("Apply")).click();   --> parent node     
driver.findElement(By.id("itemTextLink5")).click();    --> child node

我目前正在使用JDK1.6,Selenium 2.46,IE 11.由于对我正在开发的项目有一些限制,无法通过JDK和Selenium版本进行升级。

1 个答案:

答案 0 :(得分:0)

如您所说,您可以单击父元素但不能扩展意味着可能无法正确模拟点击。你试过吗

1.Try click on parent node with other different locators as linktext does not works here
2.providing the required wait to load page properly before click on parent node
3.if wait command does not work, use Thread.sleep which works for me in some cases
4. still click does not simulate properly then use javascript executor.

示例:

 WebElement element = driver.findElement(By.id("your element"));
 JavascriptExecutor executor = (JavascriptExecutor)driver;
 executor.executeScript("arguments[0].click();", element);

单击父节点树的偏离路径未展开,因此我们收到子节点的错误,因为它未显示。尝试以上建议。

谢谢你, 穆拉利