Page 1 of 1

GetAttributeValue does not work with generic arguments

Posted: Wed Jul 12, 2017 10:02 pm
by tmcpherson
I've had my own code in my test suite for a while now. After I upgrade to Ranorex 7.1, that code stopped working correctly. Specifically, if I have some InputTag inputTag, inputTag.GetAttributeValue<bool>("Checked") always returns False. Some example codes and outputs follow.

Code: Select all

var inputTag = adapter as InputTag;
Report.Info("Checked " + inputTag?.Checked + " " + inputTag?.GetAttributeValue<bool>("Checked"));
Report.Info("Maxlength " + inputTag?.Maxlength + " " + inputTag?.GetAttributeValue<int>("Maxlength"));
Report.Info("Name " + inputTag?.Name + " " + inputTag?.GetAttributeValue<string>("Name"));
(for confidentiality reasons, I replaced the actual name with 'correctName' in the below text)
Checked True False
Maxlength 2147483647 0
Name correctName correctName
Note that the Name is correct for both. I noticed that and decided to see what happened if I converted it all to a string.

Code: Select all

var inputTag = adapter as InputTag;
Report.Info("Checked " + inputTag?.Checked + " " + inputTag?.GetAttributeValue<string>("Checked"));
Report.Info("Maxlength " + inputTag?.Maxlength + " " + inputTag?.GetAttributeValue<string>("Maxlength"));
Report.Info("Name " + inputTag?.Name + " " + inputTag?.GetAttributeValue<string>("Name"));
For this, the output was actually what we'd expect:
Checked True True
Maxlength 2147483647 2147483647
Name correctName correctName
As far as I can tell, this is a regression from 7.0. Also worth noting is that I also upgraded my suite to use C# 6 and .net 4.6. I have not tested with previous C# or .net versions.

Re: GetAttributeValue does not work with generic arguments

Posted: Fri Jul 14, 2017 12:46 pm
by McTurtle
Hello tmcpherson,

I have just tested your code on the checkbox on the following webpage: w3schools - Checkbox

Unfortunately, the behavior is the same for Ranorex 6.2.1, Ranorex 7.0.1 and Ranorex 7.1.0. In all cases your first version of the code does not work and the 2nd version of the code does work.

I believe that this is correct. If you mouse over a attribute in Ranorex Spy it will actually tell you the type:
Checked_Attribute.png
Could you install Ranorex 7.0 and let me know what type is detected by Ranorex Spy for this attribute?

Reagards,
McTurtle