How to choose a value from a dictionary

Best practices, code snippets for common functionality, examples, and guidelines.
kronix
Posts: 3
Joined: Sun Nov 11, 2018 10:09 pm

How to choose a value from a dictionary

Post by kronix » Sun Nov 11, 2018 10:17 pm

Hello
1. I have a dictionary with three values
2.I have a csv file with dictionary values
3. I want the mouse action to choose the dictionary value from the csv file as a variable
4.I am getting this error:
Image


Warning - Action #7: The default value bound to 'ElementLocation' is not recognized as a valid 'Location'. Provide a valid value. - C:\Users\automat\Documents\Ranorex\RanorexStudio Projects\CRM_TEST\CRM_TEST\Recording2.rxrec:7


what am I doing wrong
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 choose a value from a dictionary

Post by odklizec » Mon Nov 12, 2018 12:41 pm

Hi,

I'm suspecting that you are trying to use a name of the item you want to click, as a mouse click Location parameter? That's unfortunately wrong. Location specifies the x/y coordinates inside the element's rectangle (element defined by the xpath). What you need to do is to assign the variable to repo item FepDropDownListNoPad. And the xpath of the element should look like body//ul/li/s[@innertext=$dyspozycja]
However, without seeing the snapshot of the element FepDropDownListNoPad, I can only guess it accepts InnerText attribute. So if the above xpaths does not work for you, please upload a Ranorex snapshot (NOT screenshot) of the dropdown list, so I (or anyone else here) can provide you with correct xpath. Thanks.
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

kronix
Posts: 3
Joined: Sun Nov 11, 2018 10:09 pm

Re: How to choose a value from a dictionary

Post by kronix » Mon Nov 12, 2018 3:42 pm

Yes, I want to do as you write. Attached snapshot. I have to do something wrong because it is still bad.
I just want to choose a value in a dictionary that is assigned to a variable; (;)
Thanks for the help
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 choose a value from a dictionary

Post by odklizec » Mon Nov 12, 2018 4:04 pm

Hi,

What exactly is wrong? Is there any error message? And what is the xpath in repo?

Unfortunately, the snapshot does not show the expanded list, but it seems the variabilized xpath you should use, should be like this:
//select[#'MainContent_Content_Rodzaj']/option[@innertext=$dyspozycja][@visible='True']
This xpath, once the var $dyspozycja is correctly filled with, correct content, should point to proper list option. Of course, you must first click the combo box, to expand the list of items.
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

kronix
Posts: 3
Joined: Sun Nov 11, 2018 10:09 pm

Re: How to choose a value from a dictionary

Post by kronix » Mon Nov 12, 2018 4:59 pm

Ok, I did as you wrote. A better snapshot attached.
I just want Ranorex to choose one of three values ​​in the dictionary. The 'var'Disposition' values ​​are defined in the data source.
Ranorex opens the dictionary, but after opening, he does not choose values
Thank you so much for help. I am a new user of ranorex.
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 choose a value from a dictionary

Post by odklizec » Tue Nov 13, 2018 9:00 am

Hi,

Thanks for the snapshot. It's much better now ;) So the xpath should look like this:

Code: Select all

body//ul/li//span[@title=$listItemName and @visible='True']
Where the listItemName should be connected to a dataconnector, containing the list item name. Attribute @visible is not quite necessary here, but it's a good practice to use it in the xpath of dynamically appearing elements, which may be always available (just hidden) in the GUI structure. So the list item will be identified only if the list is open and visible. 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