How to validate on a dynamically changing text in the text

Best practices, code snippets for common functionality, examples, and guidelines.
RekhaG
Posts: 17
Joined: Fri Sep 22, 2017 12:47 am

How to validate on a dynamically changing text in the text

Post by RekhaG » Thu Feb 08, 2018 1:51 am

Hello,

I have a text area which displays the status of a currently running job, the text keeps changing depending on which stage the job is. How can i validate the text.textvalue when it changes dynamically.
All these values are stored in a json file and i will probably read the jason and validate on each different status message that it displays in the text area.

This is the rxPath of the control
/form[@title='ProgressControlWindow']/container[1]/?/?/text[@caption='End']

Please see the attached snapshot

Thanks,
Rekha
Attachments
test.zip
(37.11 KiB) Downloaded 23 times

User avatar
Vega
Posts: 109
Joined: Mon Jul 11, 2016 2:15 pm

Re: How to validate on a dynamically changing text in the text

Post by Vega » Fri Feb 09, 2018 8:47 pm

There are a few ways you can do this depending on your test case. You could always change your path to contain a variable and then populate that variable either through code or a data source:

/form[@title='ProgressControlWindow']/container[1]/?/?/text[@caption=$myVar]

$myVar would contain the value that you are looking for at that stage of your test. This way you can reuse the same path and just change the variable throughout test execution

source: https://www.ranorex.com/help/latest/ran ... athExample

You could also do this in user code with a switch statement or something similar which can test against all acceptable values. Basically, have a method which takes the text as a parameter and check it against your expected values.