Page 1 of 1

How to validate either one of two possible attributes

Posted: Sun Jun 19, 2016 12:39 pm
by Peter546
Hi there

I'm a beginner on Ranorex.

Not sure if this is possible. Here's the situation for our test kit. We have two printers. Plug one printer in and the name of the printer is shown at the bottom of the screen. I want to validate this UI element so that the test will pass if any one of the 2 printer names are shown at the bottom. Is it possible to do this under one test action by validating either one of two attributes against a UI element? I just want the test to look at the text.

If I create two separate test actions to validate the UI element for each name, then at least one of these tests is always going to fail because we can only plug in one printer. Eg test for printer A, test for printer B. One of these will fail so is it possible to check the text for either one of these values so that the test will pass if at least one of the text is showing.

Thanks

Re: How to validate either one of two possible attributes

Posted: Mon Jun 20, 2016 8:07 am
by odklizec
Hi,

Could you please upload a Ranorex snapshot (not screenshot!) of the element in question? Also, please post the xpath you are using to identify the control.

In my opinion, the easiest way to achieve what you want is to create a xpath containing both printer names separated by "OR" operator. E.g. something like this:

Code: Select all

//text[@innertext~'How' or @innertext~'validate']
Then simply use Validate Exists action to validate the existence of the xpath.

Re: How to validate either one of two possible attributes

Posted: Mon Jun 20, 2016 9:51 am
by Peter546
Hi again

Thanks for the prompt response.

We've tried using the OR statement although we'r not entirely sure if this was done correctly.

I believe this is the xpath for the element

/form[@controlname='AlternateTill']/?/?/text[@accessiblename='Print After: BA-T500']

Please find attached the ranorex snapshot. I have also attached screenshots of the two printer types as previously mentioned.

Hope this is the correct information. If you need anything else please let me know.

Thanks

Peter

Re: How to validate either one of two possible attributes

Posted: Mon Jun 20, 2016 11:13 am
by odklizec
Hi,

Thanks for the snapshot and xpath. You can use for example xpath like this:
/form[@controlname='AlternateTill']/statusbar/text[@accessiblename='Print After: BA-T500' or @accessiblename='Print After: com2']
Then simply add the Validate Exists action, using the repoelement with above xpath. If there will be no or different printer used, the validation should fail.

Re: How to validate either one of two possible attributes

Posted: Mon Jun 20, 2016 2:08 pm
by Peter546
Working now. That's great. Thanks for your help. I'll add this to my knowledge database :D