Validation Exception
Posted: Fri Mar 27, 2015 2:44 pm
Hi,
May someone can help me out, I have small "cosmetic" problem.
My problem is when Validation.Attribute is called, even if it fails it will enter a report log. But I want only that code line in the exception is called, when it fails!
That means, if the validation passes, then it should write the message which I pass, and if it throws an exception, only the Report.Log should be called.
I hope I was somehow clear, if not please let me know.
Thanks in advance for your help
Cheers
Dan
Ranorex 5.3.0 / Win 7 / IE 11
May someone can help me out, I have small "cosmetic" problem.
My problem is when Validation.Attribute is called, even if it fails it will enter a report log. But I want only that code line in the exception is called, when it fails!
That means, if the validation passes, then it should write the message which I pass, and if it throws an exception, only the Report.Log should be called.
I hope I was somehow clear, if not please let me know.
Thanks in advance for your help
Cheers
Dan
Ranorex 5.3.0 / Win 7 / IE 11
public string GetAndValidateText(RepoItemInfo repoInfo, string attributeValue, string expectedValue) { string elementValue = string.Empty; try { repoInfo.WaitForExists(new Duration(AutomationLayerConstants.thirtySecDuration)); var element = repoInfo.CreateAdapter<Unknown>(true); if(base.ValidateElementAttributeNoReport(repoInfo, "Visible", true)) { if(element.Element.FlavorName.Equals("web") && element.Element.PreferredCapability.ShortName.Equals("select")) { WebElement webElement = element.Element; GetOptionTagAttributeValue(repoInfo, webElement, attributeValue, expectedValue, false); } else { elementValue = element.Element.GetAttributeValueText(attributeValue); Validate.Attribute(repoInfo, attributeValue, expectedValue, "The expected value {3} from item " + repoInfo.Name + " of type: " + element.Element.PreferredCapability.DisplayName + " on attribute {1} could be validated"); } } } catch(ValidationException) { Report.Log(ReportLevel.Failure, string.Format("The expected value {0}, doesn't match with value {1} found on the validated element", expectedValue, elementValue)); } return elementValue; }