Image validation

Ask general questions here.
jackrabbit
Posts: 47
Joined: Wed Mar 18, 2015 10:06 pm

Image validation

Post by jackrabbit » Fri Jun 05, 2015 7:21 pm

I need to automate a connection to the console of a VM in VmWare's vSphere software.
Because the remote connection shows up a one large image to Ranorex, I need to apply the appropriates events according to the current screen content.

For example, if the screen tells me to select which login I was to use, I must click in the right location of the screen to use that login. When I see the Windows logo at the bottom left corner of the desktop, I can end my test with a success indicator.

My UserCode has to match a few different images and react with the appropriate answer to eventually complete a login sequence and reach the desktop. In my UserCode I have a loop that matches 5 or 6 visual information that trigger an answer. If a test for image fails, it is OK, I just match the next screen, until I get a match, to provide the right answer.

Code: Select all

while (... until timeout...) 
{
            	if (Validate.ContainsImage(MyRepo.Forme.Ecran.Win2012Info, Win2012_Admin, Options,
            	                                         "Validation of the password screen", false)) {
            		Report.Log(ReportLevel.Info, "Keyboard", "Enter password.");
         		Keyboard.Press(Password);
            	}
            	    
            	if (Validate.ContainsImage(MyRepo.Forme.Ecran.Win2012Info, Win2012_Desktop, Options,
            	                                         "Validation of the Desktop 2012R2 screen'", false)) {
            		Report.Log(ReportLevel.Info, "Mouse", "Desktop 2012R2 detected.");
            		return;   // SUCCESS
            	}
            	    
            	if (Validate.ContainsImage(MyRepo.Forme.Ecran.Win2012Info, Win2012_ErrPassword, Options,
                                                     	 "Validation of invalid password screen'", false)) {
            		Report.Log(ReportLevel.Info, "Mouse", "Invalid password - new attempt.");
            		MyRepo.Forme.Ecran.Self.MoveTo("515;278");
            		MyRepo.Forme.Ecran.Self.Click("515;278");
            	}
}
My Ranorex script works fine, it logs in properly into my Windows Server 2012R2 with success, however, my test fails with the error "THE MODULE HAS FAILED BECAUSE ONE OR MORE ACTIONS HAVE FAILED.".

When I validate my images, I specified FALSE for the last parameter because I only need to check if the image exist, if if does not exist, that is fine, I just check for the next image.

I think Ranorex "remembers" these errors anyway and report the test as a failure. What can I do to fix this?

lucian.teodorescu
Posts: 82
Joined: Fri Oct 24, 2014 10:58 am
Location: Bucharest

Re: Image validation

Post by lucian.teodorescu » Mon Jun 08, 2015 9:19 am

Hi,

You are right that failed validation triggers the failure of the entire test. Because if the image does not match, it triggers Exception and ReportLevel.Failure. So here is what you need to change/add in your code:

Code: Select all

Validate.Options options = new Validate.Options();
options.ExceptionOnFail = false;
options.ReportLevelOnFailure = ReportLevel.Info;

while (... until timeout...) 
{
  ... 
}
Lucian Teodorescu
NetSun Software

jackrabbit
Posts: 47
Joined: Wed Mar 18, 2015 10:06 pm

Re: Image validation

Post by jackrabbit » Mon Jun 08, 2015 1:30 pm

Thanks!

I added your code and I replaced the last parameter in the Validate.ContainsImage with the 'options' structure , my test now runs without any errors!