While selecting the location I’m able to click on the items which are visible. But I’m unable to select the other items which are not displayed in the dropdown list. When trying to select other location in dropdown list which is not visible in the drop-down, it is clicking somewhere else.
Below is the code snippet:
IWebElement ele = driver.FindElement(By.Id("cmbLocation"));
List<IWebElement> lis = ele.FindElements(By.ClassName("ListBoxItem"));
for(int i = 0; i< lis.size(); i++) {
WebElement elem = lis.get(i).FindElement(By.name("LINWOOD"));
if("LINWOOD".contains(elem.getText())) {
lis.get(i).click();
break;
}
}
I have even tried just passing the index number as
lis.get(15).click();
I have implemented Actions class as well. But that even seem not working.
I have also faced same issue. But, I didn't find solution. For temporary I have used one solution. But that is dirty fix.
If the drop down has the scroll down bar, click on that scroll down arrow till your element is visible, And then try to click on that element. That works.