Search code examples
c#leanft

LeanFT C# Selecting a Value From Drop Down List


I'm having some trouble using Object Identification on a drop down list, what is being returned is this:

IListBox pricerBox= browser.Describe<IListBox>(new 
 ListBoxDescription
               {
                TagName = @"SELECT",
                Name = @"select"

            });

I would like to select a value from the drop down list and I tried using this as an example: How to select an option from drop down using Selenium WebDriver C#? But didn't have any luck as I'm using LeanFT in C# MS VS.

When inspecting in Chrome, this is the list box element details:

<select tabindex="1" style="width: 150px;">
<option value="3">Mc1</option><option value="11">Mc2</option><option 
 value="17">Mc3</option><option value="21">Mc4</option><option 
 value="57">Mc5</option></select>

This is what I coded so far:

  //pricer box
           IListBox pricerBox= browser.Describe<IListBox>(new 
    ListBoxDescription
           {
               TagName = @"SELECT",
               Name = @"select"

           });
            Thread.Sleep(3000);
            pricerBox.Click();

Solution

  • Please have a look at LeanFT's documentation for IListBox, the Select function looks like what you're looking for.

    pricerBox.Select("Mc3"); // No need to sleep before this