2

I have a listbox(droplist) item that is created dynamically when I click on a div/span element .. However, when I try to click on the listbox element after doing a fluent Wait , it throws me an error saying

Element is not clickable at point (741, 192). Other element would receive the click:"

If i try to use Thread.sleep(2000) then the code runs perfectly. Any ideas on how I can fix this issue and make it work in fluentWait. I have tried elementTobeClickable,elementSelectionStateToBe,presenceOfElementLocated methods in the ExpectedConditions class and they all throw the same error. I am using ChromeDriver for testing purposes .

My code and HTML snippet of the page is below

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 Snippet

<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>
user766858
  • 41
  • 1
  • Possible duplicates of http://stackoverflow.com/questions/25929195/webdriver-element-is-not-clickable-chrome – Saifur May 11 '15 at 23:14
  • Saifru,I checked the link you mentioned and none of those solutions help me. I still have the same issues. More over I am trying to figure out why fluentWait does not work and if I am using the wrong methods of ExpectedConditions class – user766858 May 12 '15 at 03:22
  • That seems like an issue with ChromeDriver itself. I ran into that before. Have you tested that on other browsers? – Saifur May 12 '15 at 03:23
  • The Firefox browser design has some issues hence I am forced to use Chrome. – user766858 May 12 '15 at 21:56

1 Answers1

0

You can try to change the XPath locator to find the element by its inner text.

fWait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//li[text() = 'Group2']"))));
Anton Angelov
  • 1,687
  • 12
  • 16
  • I had the same issues when I tried your suggestion. However for now, the getText() at the end of fWait seems to be doing the trick. fWait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//ul[@id='Group_listbox']/li[2]")))).getText(); – user766858 May 12 '15 at 21:56