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.
You can scroll to element using Winium.Elements this is available as a Nuget package https://github.com/2gis/Winium.Elements
Once you have the above you can use it in your test like this
If the above ele is a combo box then you can do the below
var comboBoxElement= ele.ToComboBox();
comboBox.Expand();
comboBox.ScrollTo("LINWOOD").Click();
If the above ele is a list box then you can do the below
var listWebElement= ele .ToList();
listWebElement.Scroll(By.Name("LINWOOD")).Click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.