Validate.Exist() fail let usercode force break

Ask general questions here.
chanow
Posts: 5
Joined: Tue Jan 15, 2013 11:00 am

Validate.Exist() fail let usercode force break

Post by chanow » Mon Feb 04, 2013 5:00 am

HI all,

I am novice with Ranorex and c# language , in my usercode, if Validate.Exists() failed then user code will break,
Is there a way let user code keep executing even if Validate.Exist() failed?

below is my code sample:

Code: Select all

for(int column = 0; column < column_cnt; column++)
     for(int row = 0; row < row_cnt; row++) {
       
          //I want those two for loops can be all executed even if Validate.Exists() fail
          string pattern = getExcel.Rows[row].Values[column];
         Validate.Exists("/dom//tr/td//*[@innertext~'"+ pattern +"']");

}
Thank you very much

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Validate.Exist() fail let usercode force break

Post by sdaly » Mon Feb 04, 2013 9:30 am

You could catch the exception, pass a Validate.Options object to Exists with exception on fail false, or use the following version of exists -

Code: Select all

Validate.Exists("rxpath", "Validating", false);

chanow
Posts: 5
Joined: Tue Jan 15, 2013 11:00 am

Re: Validate.Exist() fail let usercode force break

Post by chanow » Fri Feb 08, 2013 9:27 am

Hello sdaly

Thanks for your reply

I find why I cant keep loop going because I inputed wrong numbers of arguments....

Thank you very much