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>