Hi all,
I am not expert in Ranorex. Just like to know how I can extract the attribute value of Dynamic capability into a variable.
I can validate value using validate method but I can't store the value in a variable.
Can you please suggest
example of my code:
Validate.Attribute(Repo.Sitetrak.JobDetailsForm.Jobs.LaneIdInfo,"disabled","False");
Trouble Extracting Attribute value of Dynamic Capability
Re: Trouble Extracting Attribute value of Dynamic Capability
Hi,
You can use Get Value action to store an attribute value to variable. Translated to code, it looks like this:
...or this for 'String' attributes:
If using Info element, you need to use something like this:
BTW, if you are not yet familiar with the individual Ranorex actions, you should definitely stick with the Ranorex Recordings. There is really no advantage of using Ranorex purely in code if you don't know basics
And I'm pretty sure that using Recordings (if used properly) can greatly speed up your development process. And you can easily convert each recorded action (or even group of actions) into user code. Eventually, you can copy the code from RecordingName.cs file. This way you can easily learn the code behind each recorded action 
You can use Get Value action to store an attribute value to variable. Translated to code, it looks like this:
Code: Select all
var variableName= Repo.Sitetrak.JobDetailsForm.Jobs.LaneId.Element.GetAttributeValue("AttributeName");
Code: Select all
string variableName= Repo.Sitetrak.JobDetailsForm.Jobs.LaneId.Element.GetAttributeValueText("AttributeName");
Code: Select all
string variableName= Repo.Sitetrak.JobDetailsForm.Jobs.LaneIdInfo.FindAdapter<ProperAdapterType>().Element.GetAttributeValueText("AttributeName");


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: Trouble Extracting Attribute value of Dynamic Capability
Hi,
I actually tried below coding mechanism before asking this question. I am getting error for the below option and thought that this option is not valid for this type of property.
Attaching screen for code and the error I am getting :
ERROR: The type arguments for method 'Ranorex.Adapter.GetAttributeValue<T>(string)' cannot be inferred from the usage. Try specifying the type arguments explicitly. (CS0411)
- I used all type of tags available as well but I am not able to get the value.
2. '.GetAttributeValueText' option is not available for the element.
3. Also I don't have option to select 'FindAdapter'. Do I need to load any plug-in or specify any namespace or modify any solution setting?
Thanks
Nav
I actually tried below coding mechanism before asking this question. I am getting error for the below option and thought that this option is not valid for this type of property.
Attaching screen for code and the error I am getting :
ERROR: The type arguments for method 'Ranorex.Adapter.GetAttributeValue<T>(string)' cannot be inferred from the usage. Try specifying the type arguments explicitly. (CS0411)
- I used all type of tags available as well but I am not able to get the value.
2. '.GetAttributeValueText' option is not available for the element.
3. Also I don't have option to select 'FindAdapter'. Do I need to load any plug-in or specify any namespace or modify any solution setting?
Thanks
Nav
You do not have the required permissions to view the files attached to this post.
Re: Trouble Extracting Attribute value of Dynamic Capability
I am not sure that this is right solution or not but found the way to store the value in variable.
Here is code.
string Elementpath= Repo.Sitetrak.JobDetailsForm.Jobs.LaneIdInfo.AbsolutePath.ToString();
Element elementforvalue= Ranorex.Core.Element.FromPath(Elementpath);
string storevariable= elementforvalue.GetAttributeValueText("disabled");
Please suggest.
Here is code.
string Elementpath= Repo.Sitetrak.JobDetailsForm.Jobs.LaneIdInfo.AbsolutePath.ToString();
Element elementforvalue= Ranorex.Core.Element.FromPath(Elementpath);
string storevariable= elementforvalue.GetAttributeValueText("disabled");
Please suggest.
Re: Trouble Extracting Attribute value of Dynamic Capability
Hi,
Please upload a Ranorex snapshot (not screenshot) of the problematic element. You are most probably using something wrong or a wrong element? Please upload the snapshot and we will see. Anyway, is there a reason why you need to use code for this instead of Recording action? Have you ever tried Get Value action in recording? This way you can eliminate wrong usage of code
BTW, you don't have Find method available because you are using "laneid" instead of "laneidinfo" in your code!
Please upload a Ranorex snapshot (not screenshot) of the problematic element. You are most probably using something wrong or a wrong element? Please upload the snapshot and we will see. Anyway, is there a reason why you need to use code for this instead of Recording action? Have you ever tried Get Value action in recording? This way you can eliminate wrong usage of code

BTW, you don't have Find method available because you are using "laneid" instead of "laneidinfo" in your code!
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