Forum Discussion

dikshika114's avatar
dikshika114
Contributor
4 years ago
Solved

What is the best way to automate Dropdown which have lot of values to select (Eg: State Dropdown)

Can anyone suggest me:

1. how can i automate State dropdown which have lot of values to select (By Using TestComplete and JavaScript)

As of now i have created object of some values and clicking on them in a simple way. But it's not convenient.

 

I want to select one state (Which I want to pick from Excel File) from State Dropdown.

 

2. Is there any way to select the value from dropdown after getting the list of values with Find Element. (Like we do

most of the time in selenium)

Eg of selenium:

List L =  Dropdown.findElemets (.......................);

L.selectByName ("Pass the name of the value that you wanna select from the Dropdown");

 

Like this, is there any way to do so with Test Complete Also?????

 

12 Replies

  • Do you mean something like this?

    function Test3()
    {
      Browsers.Item(btFirefox).Navigate("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select");
      Sys.Browser().Page("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select").Panel("root").Panel(0).Article(0).Panel(0).Frame(0).Panel("editor_container").Panel("output").ShadowOutput(0).ShadowRoot(0).Panel(0).Select("pet_select").ClickItem("Cat");
    }
    • dikshika114's avatar
      dikshika114
      Contributor

      This is the object details of drop down:

      dropdownObject = //single-select//div[contains(@class, 'dropdown-toggle')] - something like this  - Defined in Name Mapping

      Below is the image of values exists in the dropdown - not defined in Name mapping - Because it can be more than 150

       

      and i want to get all the values of this dropdown at a time in a ArrayList. So that i could itrerate through that and

      could click on the exact one (whose name - i will pass into my excel sheet eg: New York) and find the values by property name like "class"

      • AGubarev's avatar
        AGubarev
        Icon for Alumni rankAlumni

        Do you know which UI framework is used in your web site?

        Maybe I can look on it and invent something