Page 1 of 1

Is this a bug? ExceptionOnFail=false not working.

Posted: Wed Sep 30, 2015 4:27 pm
by stapes
This is not meant to fail:

Code: Select all

Validate.Options option = new Validate.Options(ReportLevel.Info);
         	option.ExceptionOnFail=false;
            Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'AgileMobileApp.StandardLoginPage.AdvancedButton'.", repo.AgileMobileApp.LoginPage.AdvancedLoginPage.StandardButtonInfo);
            if(Validate.Exists(repo.AgileMobileApp.LoginPage.StandardLoginPage.AdvancedButton,"", option))
            {
    			// *** Click the Advanced Button to go there.
        		Report.Log(ReportLevel.Info, "Touch", "Touch item 'AgileMobileApp.LoginPage.StandardLoginPage.AdvancedButton' at 119;38", repo.AgileMobileApp.LoginPage.StandardLoginPage.AdvancedButtonInfo);
    			repo.AgileMobileApp.LoginPage.StandardLoginPage.AdvancedButton.Touch("119;38");
            }
However, it causes a stop:

Failed to find item 'AgileMobileAppRepository.AgileMobileApp.LoginPage.StandardLoginPage.AdvancedButton'.
No element found for path '/mobileapp[@title='uk.co.documotive.mobile.documobile.agile']/form[@title='Login']//container[@containertype='Linear']/container[@contain
ertype='Relative']/?/?/button[@text='Advanced']' within 1.5m.
Show/Hide Stacktrace

Re: Is this a bug? ExceptionOnFail=false not working.

Posted: Wed Sep 30, 2015 4:54 pm
by krstcs
If you are just wanting to check if something exists in order to decide whether to do some action or not, you should probably use the Exists() method on the repo object's ItemInfo object instead.

Code: Select all

if(repo.AgileMobileApp.LoginPage.StandardLoginPage.AdvancedButtonInfo.Exists()) {
  //do your stuff here
}
Try to only use Validate when you actually need to validate something.

As for the error, I'm not sure, I don't use Validate.Exists in that way, maybe someone else knows more.

Re: Is this a bug? ExceptionOnFail=false not working.

Posted: Wed Sep 30, 2015 5:18 pm
by stapes
Thanks. That works.