Is this a bug? ExceptionOnFail=false not working.

Ask general questions here.
stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Is this a bug? ExceptionOnFail=false not working.

Post by stapes » Wed Sep 30, 2015 4:27 pm

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

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Wed Sep 30, 2015 4:54 pm

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.
Shortcuts usually aren't...

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

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

Post by stapes » Wed Sep 30, 2015 5:18 pm

Thanks. That works.