how to iterate through drop down box

Ask general questions here.
strannik
Posts: 60
Joined: Tue Apr 29, 2014 3:00 pm

how to iterate through drop down box

Post by strannik » Tue Nov 04, 2014 3:32 pm

Hi All,

Is it possible to iterate through drop down box and select an item? For an example: I need to create car and assign driver to it from drop down box after that I need to create a new car and assign second driver from drop down box to it and so on. I created Simple Data table for drivers and vehicles but my script always selects first driver in drop down box. Please see an attachment.
You do not have the required permissions to view the files attached to this post.

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

Re: how to iterate through drop down box

Post by odklizec » Tue Nov 04, 2014 6:05 pm

Hi,

It' hard to say what's wrong without seeing your recording, elements xpaths and connection of data table to module variable.

Here is a simple example how to use data driven approach with combo boxes:

In repository, add a variable representing the name of driver you want to select from combo. In my example "driveLetter"...
ListItemName.png
If your list of names is long and some names may not be visible after expanding the combo box, use InvokeAction with EnsureVisible command. This should make the "invisible" item visible.

Now create the data source with names that should be selected in combo box...
DataSource.png
And finally, connect the data table column with the module variable:
DataBinding.png
Finally, run the test suite. If everything is set correctly and it still selects only first name, then there is probably something else wrong. Selecting items in combo boxes is always tricky (depends of used technology).

Could you please post the snapshot of combo box in question and eventually screenshot of your recording module with visible selection actions and repository items?
You do not have the required permissions to view the files attached to this post.
Last edited by odklizec on Tue Nov 04, 2014 7:47 pm, edited 1 time in total.
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

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: how to iterate through drop down box

Post by krstcs » Tue Nov 04, 2014 6:13 pm

Yes, it is possible with data-driven testing. You will have to "variable-ize" your selection for the drop-down and pass in the value you want.

There are many ways to do this.

Also, each browser will behave differently when trying to select a value from the list, so you may have to write some code.


One thing you could try instead is just typing in the value you want. Most drop-down lists will automatically select the item that matches what is typed into the drop-down. Just do the following:

1. Mouse -> Click -> Left -> Center -> DropdownRepoItem
2. Key -> Sequence -> $value -> DropdownRepoItem


This should work for all browsers, but it might not. It's worth a try.
Shortcuts usually aren't...

strannik
Posts: 60
Joined: Tue Apr 29, 2014 3:00 pm

Re: how to iterate through drop down box

Post by strannik » Tue Nov 04, 2014 7:42 pm

Hi guys,

Thank you very much for your help.

I just added Driver names to Simple Data Table. Actually how it is working when I select Add button it will display all drivers where you have to select driver I used "enter" and assign it as variable and after that connect it to data table. Everything is working perfectly.