Page 1 of 1

Image and Text based validation Fails

Posted: Thu Feb 14, 2013 9:32 pm
by nhassan
I am automating a web login page that has Email, First Name, Last Name and Username as mandatory text fields. When I leave all of them blank and click the login button, it generates the correct error message (screenshot 5.png) and the recording passes. Now, if I enter the First Name and click login again, the correct error message is shown (screenshot 6.png). However, the recorder fails at this point failing to validate the error message(6.png). I have tried both image and text based comparison.

Please advise.

Thanks,

Re: Image and Text based validation Fails

Posted: Fri Feb 15, 2013 8:08 am
by mdgairaud
Hi,

In a recent automation I need to make an image comparison step. Wrote about it in a post, hope it helps:

http://www.ranorex.com/forum/ranorex-im ... tml#p18500

at least you can have a % of simmilarity between images because even a pixel can ruin the comparison



regards,
Mateo.

Re: Image and Text based validation Fails

Posted: Fri Feb 15, 2013 10:28 am
by Support Team
Hi,

I think performing image based validation only makes sense if you are not able to perform text based validation.
So, what exactly is the problem when validating the text.

Regards,
Tobias
Ranorex Team

Re: Image and Text based validation Fails

Posted: Fri Feb 15, 2013 4:26 pm
by nhassan
Hi,
My problem is that the same repository item has two different texts stored:

1) When the user doesn't enter anything, 5.png is shown in the UI and validated passes
2) When the user enters the firstname, 6.png is shown in the UI and the validation fails with the following error:

Attribute 'InnerText' of element for item 'xxxRepository.yyy.CommandErrors1' does not match the specified value (element is not valid).

Please advise.

Re: Image and Text based validation Fails

Posted: Mon Feb 18, 2013 5:42 pm
by Support Team
Hi,

You could for instance add a UserCode action to your Recording where you can validate if whether the first or the second text is displayed, you could set the ExceptionOnFail property to false in order to prevent Ranorex from stopping the execution when the validation fails.

Regards,
Markus

Re: Image and Text based validation Fails

Posted: Thu Feb 21, 2013 7:04 pm
by nhassan
Hi,
Would you have an example code snippet for the UserCode action where you can validate if whether the first or the second text is displayed?

Re: Image and Text based validation Fails

Posted: Mon Feb 25, 2013 6:51 pm
by Support Team
Hello,

You can check that using the "Validate.Exists()" method using the RanoreXPath of the item. The last parameter of the method is the ExceptionOnFail property.
For example:
bool formExists = Validate.Exists("/form[@title='Calculator']", 3000, "Validate Calculator", false);

if(formExists)
{
	Report.Info("Calculator exists");
}
else
{
	Report.Info("Calculator doesn't exist");
}
Please modify this example for your needs.

Regards,
Bernhard