Hi,
I am working on a scenario wherein I have to store bunch of elements from a drop down into a list and then select any of them whichever I wish
That selection will also be variable base like parameterization, NO HARDCODING" any one specific value
Please help me how to store elements in a list
Please let me know for more info
Regards
How to store elements in a list and then click on any one of them
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to store elements in a list and then click on any one of them
Hi premravi,
With more information, including a Ranorex Snapshot, I may be able to better assist you. Nonetheless, please see the below as it may be enough to point you in the right direction.
To add all options of a select box to a list, first, create an item in your Ranorex Repository which points to all option tags of the desired select box element, for example:
Next, use the following code to create a Ranorex OptionTag Adapter for each option returned from the above repository item (named allOptionElements in the example below). This will store each option element in a list so you can hopefully achieve what you need.
I hope this helps!
Regards,
Ned
With more information, including a Ranorex Snapshot, I may be able to better assist you. Nonetheless, please see the below as it may be enough to point you in the right direction.
To add all options of a select box to a list, first, create an item in your Ranorex Repository which points to all option tags of the desired select box element, for example:
Code: Select all
./?/?/select/option
Code: Select all
var repo = SampleProjectRepository.Instance;
var allOptionElements = repo.myDom.allOptionElementsInfo;
IList<OptionTag> allOptions = allOptionElements.CreateAdapters<OptionTag>();
foreach (OptionTag option in allOptions)
Report.Info(option.Element.GetAttributeValueText("Value"));
Regards,
Ned
Re: How to store elements in a list and then click on any one of them
Hi,
Please find the attached image and the snapshot which helps you in designing the xpath and code snippet as well
Regards
Please find the attached image and the snapshot which helps you in designing the xpath and code snippet as well
Regards
- Attachments
-
- dropdowncode.png (77.3 KiB) Viewed 1527 times
-
- DropDownElements.rxsnp
- (130.91 KiB) Downloaded 28 times
Re: How to store elements in a list and then click on any one of them
Hi,
We've discussed a similar topic few days ago here:
viewtopic.php?f=4&t=13773&p=53973#p54021
Basically, you should use the same approach, mentioned in this post.
I just don't understand the need of creating list of elements, if you simply want to click one of available table elements? If you need to click just one particular element, you can use xpath like this:Where itemName variable you can simply bind to a data connector of your choice and fill it from there with name of item you want to click. No list and code is needed then.
In case you prefer to create coded list and do all clicking via code, you should follow the above linked post. To create list of available elements, you should use xpath like this:This xpath simply returns all span elements from the table of your choice.
We've discussed a similar topic few days ago here:
viewtopic.php?f=4&t=13773&p=53973#p54021
Basically, you should use the same approach, mentioned in this post.
I just don't understand the need of creating list of elements, if you simply want to click one of available table elements? If you need to click just one particular element, you can use xpath like this:
Code: Select all
/dom[@domain='dashboard.eu-iport.nielsen-iwatch.com.aws-w-np.nielsencsp.com']//div[@class='edit-view-container']/?/?/div[@class='left-panel-container']//div[@class='navbar jqx-reset jqx-widget jqx-navigationbar']//div[@class='user-image-list tree-grid']/?/?/div[@class='mj-treegrid-container']//table/tbody/tr/td//div[@class='mj-text mj-nowrap']/span[@class='text' and @innertext=$itemName]
In case you prefer to create coded list and do all clicking via code, you should follow the above linked post. To create list of available elements, you should use xpath like this:
Code: Select all
/dom[@domain='dashboard.eu-iport.nielsen-iwatch.com.aws-w-np.nielsencsp.com']//div[@class='edit-view-container']/?/?/div[@class='left-panel-container']//div[@class='navbar jqx-reset jqx-widget jqx-navigationbar']//div[@class='user-image-list tree-grid']/?/?/div[@class='mj-treegrid-container']//table/tbody/tr/td//div[@class='mj-text mj-nowrap']/span[@class='text']
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: How to store elements in a list and then click on any one of them
Hi,
Thanks a lot for your response,
Yes I remember we discuss this before, but the requirement is bit different from the previous one
I do not have to click on all elements available in the drop down
I just want to click on any one whichever I will pass it in a variable
Basically I am trying to store all the elements which are available in the list into a "variable" and then I can pass any value through that variable and it will click to that specific value
Please help to design this piece of code
I am trying but getting few errors
Please find the attached screenshot
Thanks a lot for your response,
Yes I remember we discuss this before, but the requirement is bit different from the previous one
I do not have to click on all elements available in the drop down
I just want to click on any one whichever I will pass it in a variable
Basically I am trying to store all the elements which are available in the list into a "variable" and then I can pass any value through that variable and it will click to that specific value
Please help to design this piece of code
I am trying but getting few errors
Please find the attached screenshot
- Attachments
-
- SpanListError.png (148.21 KiB) Viewed 1511 times
Re: How to store elements in a list and then click on any one of them
And here is why I don’t understand the need to store all items in variables or list. All you need is a ‘global’ repoitem, pointing to all items of given type in table and where InnerText attribute is filled with variable. Now once the variable is filled, preferably from data connector, xpath finds exactly the element you want to click. And that’s all you need. No code is required at all

Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: How to store elements in a list and then click on any one of them
LOL!!.......
Sure, I will follow this approach,
As far as I understand, you try to avoid writing code wherever possible
But your suggestions are really helpful
Regards


Sure, I will follow this approach,
As far as I understand, you try to avoid writing code wherever possible

But your suggestions are really helpful

Regards
Re: How to store elements in a list and then click on any one of them
Hi,
You are right. I just don't like over complicate simple things
RanoreXpaths are quite powerful and a lot of things can be done with them. Custom code is of course necessary in TA, no matter what tell us various marketing materials. But there is really no point to code something, that can be achieved by much more elegant way. And another reason is, that each line of custom code is a potential source of bugs 
You are right. I just don't like over complicate simple things


Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: How to store elements in a list and then click on any one of them
Hi,
The similar kind of requirement I come up with with a small tweek in it
Basically now I have to search for a file in the file explorer window
I am following the approach of presskeys the name of the file and click open it is working
As of now the name of the file is hardcoded
I have to store it in a variable and call it whichever file name I want
I tried it but its not working
Please find attached screenshot and snapshot
Inside Form Open >>>>Text 1148 is the location of the text field in the file explorer native window
The similar kind of requirement I come up with with a small tweek in it
Basically now I have to search for a file in the file explorer window
I am following the approach of presskeys the name of the file and click open it is working
As of now the name of the file is hardcoded
I have to store it in a variable and call it whichever file name I want
I tried it but its not working
Please find attached screenshot and snapshot
Inside Form Open >>>>Text 1148 is the location of the text field in the file explorer native window
- Attachments
-
- FileExplorer.rxsnp
- (117.84 KiB) Downloaded 17 times
-
- selectImageFromFileExplorer.png (124.33 KiB) Viewed 1485 times
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to store elements in a list and then click on any one of them
Hi Premravi,
For this, you should be able to use a standard recorder variable and bind it to a parameter. I highly recommend checking out this part of our user guide as it goes into depth on this topic. The pictures below may also better explain what is recommended to achieve this.
Cheers,
Ned
For this, you should be able to use a standard recorder variable and bind it to a parameter. I highly recommend checking out this part of our user guide as it goes into depth on this topic. The pictures below may also better explain what is recommended to achieve this.
Cheers,
Ned