Validate empty field fails with (null)

Ask general questions here.
mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Validate empty field fails with (null)

Post by mrt » Fri Jul 29, 2022 4:00 pm

Hi all,

I have had a problem for some time, maybe we can find a solution now. :)

I enter values on some webpage, save it and then validate if all entered values are set correctly.
This works without any issues, as soon as I leave values empty.

Because then, the validation fails with error message (actual='(null)', expected=''):
Attribute 'Value' of element for item 'txt_TextAttribute' does not match the specified value (actual='(null)', expected='').
I use the Validate.AttributeEqual directly from a recording.
In Spy I see the 'Value' as well as the 'TagValue' as empty, TagValue is not even greyed out, so the attribute seems to be there, but the value is not read as empty string, but as "(null)" for some reason.

There are some suggestions across the forum, but these are rather old (Ranorex 2.3.6) or involve adding some stuff to the RXpath, which seems not to be sufficient, because I want to use the exact same repository item for entering and validating of filled as well as empty fields.

Is there any better solution or any switch to get this working without the need to re-code my own Validation method?

thank you, BR mrt

csaszi89
Posts: 41
Joined: Mon Jan 17, 2022 12:10 pm

Re: Validate empty field fails with (null)

Post by csaszi89 » Wed Aug 03, 2022 7:16 am

Hi mrt,

I have no clue why you got "null" as Value.
Perhaps, timing issue and the element is not initialized correctly when you access it? This case, try to put some delay.
I see, you do not want to modify your current validation step. But, if I had a code module, I would use this to avoid such errors:

Code: Select all

Validate.IsTrue(string.IsNullOrEmpty(myElement.Value));
Greetings,
Gyuri

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: Validate empty field fails with (null)

Post by mrt » Thu Aug 04, 2022 9:23 am

Hi,

yes, me too. Maybe it is something with the application, I will talk to devs to get more details.
Delay or similar would not work, it also happens when executed manually on a already fully loaded page.

thanks anyway!

csaszi89
Posts: 41
Joined: Mon Jan 17, 2022 12:10 pm

Re: Validate empty field fails with (null)

Post by csaszi89 » Thu Aug 04, 2022 10:12 am

Hi again,

I was curious about this stuff, so I have just checked the working of our input elements.
The situation is the same, TagValue and Value attributes are not greyed out (in Spy), but during debugging they have "null".
When an input is entered then the Value and TagValue attributes are not "null" any longer.
What I saw, Value and TagValue attributes never had string.Empty value, even if a value is entered and cleared.
So, what I assume, this is an internal behaviour of Ranorex, they leave the values as "null" (and not empty) until an input is entered.

Greetings,
Gyuri

dailyak77
Posts: 1
Joined: Fri Aug 26, 2022 1:31 pm

Re: Validate empty field fails with (null)

Post by dailyak77 » Fri Aug 26, 2022 1:35 pm

There is a table with about 30 columns. I need to select about 8 columns out of it. I cannot use where clause because I want to select all the data. I need all of this data to be pushed into Power BI model to do further analysis
https://routerlogin.ltd/
https://pikashow.ltd/