Changing buttons into variables

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 7
Joined: Thu Jul 31, 2014 4:14 pm

Changing buttons into variables

Post by sfeldman » Mon Jun 27, 2016 4:12 pm


I am trying to test choosing different styles for orders. There are 92 styles in all and they are each separate buttons. I was wondering if there was a way that I could make these buttons into variables since they are all separate repository items. I tried making their paths into variables but that didn't seem to work. Also, I'm not very good at coding so I mostly use Ranorex Recording. Thanks!
You do not have the required permissions to view the files attached to this post.

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

Re: Changing buttons into variables

Post by krstcs » Mon Jun 27, 2016 7:00 pm

There are several things you could do, but it depends a lot on what your data looks like. Can you post an example of what data you want to pass into your module to tell it what to select? Is it the model image number ("Model Image - 01"), the img reference hash in the img tag's src property, etc.?

I would guess the model image number. If that is the case, you can do this:

Code: Select all

StyleView => //#'styleView']
..StyleButton => /div/table/tbody/tr/td[@innertext~$varModelImageNumber]/parent::tr/parent::tbody/parent::table/parent::div/div[@class='iconSelect']
This also depends on what part of the image/icon is clickable. You could add "/a" or "/a/img" if needed.

Also, you could make the variable lookup like this: ".../td[@innertext~'Model\ Image\ \-\ ' + $varModelImageNumber]..." if you just want to pass in "01", "02", etc.

Remember that you can make as many versions of a repo item as you want as long as they have different names, and you and make their paths slightly different. This can allow you to work out what works and what doesn't.
Shortcuts usually aren't...