Get Value Returning Empty String

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
knahvi
Posts: 5
Joined: Wed May 29, 2019 8:14 pm

Get Value Returning Empty String

Post by knahvi » Tue Jun 04, 2019 5:52 pm

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.

Code SS.PNG
RepoItem SS.PNG
Recording SS.PNG
You do not have the required permissions to view the files attached to this post.

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Get Value Returning Empty String

Post by Vega » Tue Jun 04, 2019 7:38 pm

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:
forum3.png
forum4.png
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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get Value Returning Empty String

Post by odklizec » Tue Jun 04, 2019 8:36 pm

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?
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

knahvi
Posts: 5
Joined: Wed May 29, 2019 8:14 pm

Re: Get Value Returning Empty String

Post by knahvi » Wed Jun 05, 2019 6:32 pm

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?

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Get Value Returning Empty String

Post by Vega » Thu Jun 06, 2019 8:20 pm

knahvi wrote:
Wed Jun 05, 2019 6:32 pm
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?
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?