【发布时间】:2015-05-11 22:24:06
【问题描述】:
我有一个 listbox(droplist) 项目,当我单击 div/span 元素时会动态创建它。但是,当我尝试单击 listbox 时element 在做了一个流利的 Wait 之后,它给我一个错误说
元素在点 (741, 192) 处不可点击。其他元素会收到点击:"
如果我尝试使用Thread.sleep(2000),那么代码运行完美。关于如何解决此问题并使其在fluentWait 中工作的任何想法。我在 ExpectedConditions 类中尝试了 elementTobeClickable,elementSelectionStateToBe,presenceOfElementLocated 方法,它们都抛出相同的错误。我正在使用 ChromeDriver 进行测试。
我的代码和页面的 HTML sn-p 在下面
WebElement elt = driver.findElement(By.xpath("//*[@id='GroupTT']/span[2]/span/span[1]")); //Clicking on the span so that listbox will be activiated
Actions act = new Actions(driver);
act.moveToElement(elt).click().build().perform();
fWait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//ul[@id='Group_listbox']/li[2]")))); //Thread.sleep(2000) works fine here.
driver.findElement(By.xpath("//ul[@id='Group_listbox']/li[2]")).click();
HTML 片段
<div >
<ul unselectable="on" id="Group_listbox" role="listbox" style="overflow: auto; height: auto;">
<li tabindex="-1" role="option" unselectable="on" class="k-item" data-index="0"> Group1 </li>
<li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" data-index="1"> Group2 </li>
<li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" data-index="1"> Group3 </li>
</ul>
</div>
【问题讨论】:
-
Saifru,我检查了你提到的链接,这些解决方案都没有帮助我。我仍然有同样的问题。此外,我试图弄清楚为什么 fluentWait 不起作用,以及我是否使用了 ExpectedConditions 类的错误方法
-
这似乎是 ChromeDriver 本身的问题。我以前遇到过。你在其他浏览器上测试过吗?
-
Firefox 浏览器设计存在一些问题,因此我不得不使用 Chrome。
标签: java ajax listbox webdriver fluent