Image and Text based validation Fails

Ranorex Studio, Spy, Recorder, and Driver.
nhassan
Posts: 10
Joined: Tue Jan 22, 2013 10:05 pm

Image and Text based validation Fails

Post by nhassan » Thu Feb 14, 2013 9:32 pm

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,
You do not have the required permissions to view the files attached to this post.

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: Image and Text based validation Fails

Post by mdgairaud » Fri Feb 15, 2013 8:08 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Image and Text based validation Fails

Post by Support Team » Fri Feb 15, 2013 10:28 am

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

nhassan
Posts: 10
Joined: Tue Jan 22, 2013 10:05 pm

Re: Image and Text based validation Fails

Post by nhassan » Fri Feb 15, 2013 4:26 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Image and Text based validation Fails

Post by Support Team » Mon Feb 18, 2013 5:42 pm

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

nhassan
Posts: 10
Joined: Tue Jan 22, 2013 10:05 pm

Re: Image and Text based validation Fails

Post by nhassan » Thu Feb 21, 2013 7:04 pm

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Image and Text based validation Fails

Post by Support Team » Mon Feb 25, 2013 6:51 pm

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