-
Notifications
You must be signed in to change notification settings - Fork 143
Description
Hi,
While selecting the location I’m able to click on the list items which are visible. But I’m unable to select the other locations 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.
I.e. I’m able to click the list items up to “CARTAGE LA” (the location in dropdown list are visible up to CARTAGE LA). For the other locations, it is clicking outside the list.
WebElement ele = driver.findElement(By.id("cmbLocation"));
ComboBox combo = new ComboBox(ele);
combo.expand();
List<WebElement> lis = ele.findElements(By.className("ListBoxItem"));
lis.get(42).click();
I used list index to locate elements. How can I locate them with visible text? I used the following code but it's not working.
WebElement ele = driver.findElement(By.id("cmbLocation"));
ComboBox combo = new ComboBox(ele);
combo.expand();
List<WebElement> lis = ele.findElements(By.className("ListBoxItem"));
for(int i = 0; i< lis.size(); i++) {
WebElement elem = lis.get(i).findElement(By.name("ATLANTA"));
if("ATLANTA".contains(elem.getText())) {
lis.get(i).click();
break;
}
}