Store the dropdown values into a list and compare

Ask general questions here.
premravi
Posts: 114
Joined: Tue Jan 08, 2019 1:55 pm

Store the dropdown values into a list and compare

Post by premravi » Mon Dec 16, 2019 4:22 pm

Hi,

I am trying to select any of the values available in the drop down using tagValue which is not usefull

I want to select the value from the drop down using "text"

Moreover after that I want to store all the values available in the drop down in to a List

Please help me to understand how can click any value in the drop down using Get Text

And after that how can I store all values in a LIST

I have attached the drop down screenshot and snapshot both

Please help me with the issue

Regards
Attachments
DropDown1Snapshot.rxsnp
(56.55 KiB) Downloaded 2 times
DropDown1.PNG
DropDown1.PNG (15.66 KiB) Viewed 63 times
DropDown2.PNG
DropDown2.PNG (16.52 KiB) Viewed 63 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5459
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Store the dropdown values into a list and compare

Post by odklizec » Tue Dec 17, 2019 9:05 am

Hi,

I see you are using Chrome, which has a known limitation regarding combo boxes. To select an item in the list, you will have to KeySequence, instead of mouse click. See this post:
https://www.ranorex.com/forum/code-for- ... tml#p51870

As for obtaining list of items in code, you can use this approach:

You need to create a repo item, which points to all items of given combo box
/dom[@page='']//div[#'wrapper']//div//select[@visible='true']/option
The problem is, that there are no IDs to uniquely identify individual combo boxes, so you will have improve the xpath to find only the items from actually expanded combo box. This should probably work:
/dom[@page='']//div[#'wrapper']//div//select[@visible='true']/option[@visible='true']

Now you can use this code (as user code action in Recording module), which must be linked to above created repo element...

Code: Select all

public void GetListItems(RepoItemInfo selectItemsInfo)  // where listItemsInfo points to the repo element, with xpath returning list of all select tag items
    {
        IList <Ranorex.OptionTag> selectItemsList = selectItemsInfo.CreateAdapters<Ranorex.OptionTag>(false);
        foreach (Ranorex.ListItem selectItem in selectItemsList)
        {
            //do whatever you want with obtained select item ;)
        }
    }
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

premravi
Posts: 114
Joined: Tue Jan 08, 2019 1:55 pm

Re: Store the dropdown values into a list and compare

Post by premravi » Tue Dec 17, 2019 2:52 pm

Hi,

Individual values in the drop down are not identified as the drop down is a container

While Storing it into a list Options Tag is throwing an error

I tried with Select tag and container but it is not working out

Mainly the first objective now is to click any specific value from the drop down using the name not the tagValue

Is there any other way can we try Sir

Regards

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5459
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Store the dropdown values into a list and compare

Post by odklizec » Tue Dec 17, 2019 2:56 pm

Hi,

As I mentioned in previous post, individual combo box items cannot be tracked and clicked in Chrome. You must use Key Sequence action instead. See the link in my previous answer.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration