Hello,
I'm attempting to grab a the value of a GUI element in a windows application and compare it to a stored value in our database. In the Ranorex report I am not getting any errors finding or setting the element but when I use Report.Log it returns blank or when I use an if statement it comes back false when it should be true.
I made sure to bind the variable from the recording to the user code.
Get Value Returning Empty String
Get Value Returning Empty String
You do not have the required permissions to view the files attached to this post.
Re: Get Value Returning Empty String
My Guess would be that you might be pulling from the wrong attribute. If you are able to provide a Ranorex Snapshot of the element in question, we should be able to quickly see which attribute holds the value you are trying to read. Sometimes you can find the value in several attributes, and sometimes not.... It really depends on your application and the control itself.
If you open Spy and track the object, take a look at its attributes:
And if you are interested in the coded approach, I simply right clicked the actions above -> View code:
Hope this helps
If you open Spy and track the object, take a look at its attributes:
And if you are interested in the coded approach, I simply right clicked the actions above -> View code:
Code: Select all
Report.Log(ReportLevel.Info, "Get Value", "Getting attribute 'Value' from item 'Google.BtnK' and assigning its value to variable 'NewVariable'.", repo.Google.BtnKInfo, new RecordItemIndex(0));
NewVariable = repo.Google.BtnK.Element.GetAttributeValueText("Value");
Delay.Milliseconds(0);
Report.Log(ReportLevel.Info, "User", NewVariable, new RecordItemIndex(1));
Hope this helps
You do not have the required permissions to view the files attached to this post.
Re: Get Value Returning Empty String
Hi,
I see one potential logic error, which may lead to unexpected result. The ContainerID element in your repo, uses an xpath, pointing to the text element, identified by ASContainerID variable. And then in recording, you are using the same variable for storing the GetValue output. Do you see the problem?
How exactly is identified the ContainerID? Unless you somehow fill the ASContainerID variable, before calling GetValue action, the variable ASContainerID is most probably empty? And therefore, Ranorex finds first text element with empty text attribute. And this is also why GetValue returns empty ASContainerID. It’s simple as that. What you need to do, is to either fill the ASContainerID variable (before accessing ContainerID element by GetValue) or completely change the way the ContainerID element is identified. Hope this helps?
I see one potential logic error, which may lead to unexpected result. The ContainerID element in your repo, uses an xpath, pointing to the text element, identified by ASContainerID variable. And then in recording, you are using the same variable for storing the GetValue output. Do you see the problem?

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: Get Value Returning Empty String
I was actually able to find the problem. The action get value in my recording had the name set to "GetAutoStoreContainerID". When set to "Text" from the dropdown options it fixed the issue.
I'm having a similar issue now though with using a variable in the key sequence action. If I don't use a variable and just use plain text it has no problem typing into a text box, but as soon as I set it to a variable with a default value of lets say "1", nothing gets typed into the text box?
I'm having a similar issue now though with using a variable in the key sequence action. If I don't use a variable and just use plain text it has no problem typing into a text box, but as soon as I set it to a variable with a default value of lets say "1", nothing gets typed into the text box?
Re: Get Value Returning Empty String
Good to hear you were able to get it resolved; sounds like you were pulling from the wrong attribute. For your follow up question, would you be able to post a screenshot of your action or code? In the report, you should be able to see the current values of the variables, does the value show as expected in the report?knahvi wrote: ↑Wed Jun 05, 2019 6:32 pmI was actually able to find the problem. The action get value in my recording had the name set to "GetAutoStoreContainerID". When set to "Text" from the dropdown options it fixed the issue.
I'm having a similar issue now though with using a variable in the key sequence action. If I don't use a variable and just use plain text it has no problem typing into a text box, but as soon as I set it to a variable with a default value of lets say "1", nothing gets typed into the text box?