Code module skip fail
Posted: Wed May 20, 2015 12:01 pm
Hello, i am trying to make a validation function and give it a Ranorex Repository item as a variable :
When i am using this function inside one of my code modules, for example :
if the repository item could not be found, ranorex will stop the code module and throw an exception. (because it couldn't find the item and therefore couldn't pass the item's path and wouldn't get inside the function).
what can i do to make ranorex skip the fail and let me handle it\get the item's path (which will be dynamic in case of a change in the repository)?
Code: Select all
/// <summary>
/// Validate existance of a given Ranorex Path
/// </summary>
/// <param name="path">Ranorex path of a ranorex repository item.</param>
/// <returns>true if path exists, false otherwise.</returns>
public static bool Ranorex_Validate(Ranorex.Core.RxPath path)
{
//Write to log
//LogWriter.Log("_Entered Ranorex_Validate()."); //Write to log
//Set Flag to false
ExistFlag = false;
//Validate path
try
{
ExistFlag = Ranorex.Validate.Exists(path,3000,"Couldn't find {0} path.",false);
if(ExistFlag)
{
//LogWriter.Log("Validate succeeded, return true."); //Write to log
//LogWriter.Log("_Exiting Ranorex_Validate()."); //Write to log
return true; //Path exists.
}
}
catch (Exception ex)
{
LogWriter.Log("Exception occured: " + ex.Message); //Write to log
}
LogWriter.Log("Validation path variable set to: " + path.ToString()); //Write to log
LogWriter.Log("Validate failed, return false."); //Write to log
return false;
}
Code: Select all
if(General.Library.General.Ranorex_Validate(repo.WINWORD.Info_Protect_Document_Options.MarkAsFinal.GetPath()))
{
MessageBox.Show("Pass");
}
else
MessageBox.Show("Fail");
what can i do to make ranorex skip the fail and let me handle it\get the item's path (which will be dynamic in case of a change in the repository)?