1

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.

daedsidog
  • 1,732
  • 2
  • 17
  • 36
naazneen3264
  • 315
  • 2
  • 7
  • 22
  • select option and i have a scenario where i need to scroll table as well – naazneen3264 Dec 05 '18 at 07:24
  • Am automating desktop application using winium driver with c# – naazneen3264 Dec 05 '18 at 07:53
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Dec 05 '18 at 08:42

2 Answers2

0

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.

K.Krishnakanth
  • 127
  • 1
  • 15
0

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();
shiva
  • 1
  • 1