How to validate an input based on variable

Best practices, code snippets for common functionality, examples, and guidelines.
mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

How to validate an input based on variable

Post by mmahra » Thu Mar 05, 2020 7:43 am

Hello,

I have a step where I have to enter an input and validate on the entered input
I have set this input as variable and added validation for the innertext to match the variable, however, the execution fails.
Last edited by mmahra on Thu Mar 19, 2020 11:15 am, edited 1 time in total.

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

Re: How to validate an input based on variable

Post by odklizec » Thu Mar 05, 2020 8:09 am

Hi,

Apparently, the InnerText attribute of NewPropName element is empty. Could you please post a Ranorex snapshot (NOT screenshot) of the element, along with the xpath you are using for this element in repo?

My guess is that the InnerText of NewPropName is simply empty? Or the xpath of NewPropName returns more than one element and one of them has empty InnerText?
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to validate an input based on variable

Post by mmahra » Thu Mar 05, 2020 11:11 am

XPath: /dom[@domain='banzai-3001-0-0-432edda-3.jivelandia.com']//input[#'newPropName']
Last edited by mmahra on Thu Mar 19, 2020 11:14 am, edited 1 time in total.

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

Re: How to validate an input based on variable

Post by odklizec » Thu Mar 05, 2020 11:20 am

Hi,

Thanks for the snapshot and xpath. As I've expected, the InnerText of given element is empty. So the validation is correct...
InnerText_empty.png
InnerText_empty.png (42.02 KiB) Viewed 135 times
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to validate an input based on variable

Post by mmahra » Thu Mar 05, 2020 11:59 am

So How can I validate that the input field has the entered value in the key sequence?.
Actually validation are big challenge to me, everything passes when I just set it to "Exists" but it might fail in actual execution,however, Ranorex is execution success.

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

Re: How to validate an input based on variable

Post by odklizec » Thu Mar 05, 2020 12:14 pm

Hi,

Validation "Exists" validates the existence of pointed repo element, not its content. So if the element exists validation passes. If you want to validate the content of an element, you must validate a proper attribute, which contains the entered text.

Could you please create a snapshot of the problematic input element AFTER the input is filled with text? Ideally, add create snapshot action right after KeySequence action. Then simply check, in which property is store the entered text.
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to validate an input based on variable

Post by mmahra » Thu Mar 05, 2020 12:57 pm

Hi again,

It worked when Att. equal TagValue

Thats really awesome, Thank again and again

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

Re: How to validate an input based on variable

Post by odklizec » Thu Mar 05, 2020 1:13 pm

Hi,

I'm glad it helped. This is why you always need to check the available attributes with Spy ;)
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