Hi,
i want to make such validation in my test, but i cant find how to get true or flase from Validate.Attribute
if(text=="test" && Validate.Attribute(repo.smth.smthInfo, "Checked","True"); ){
than bla bla bla
}
but i am getting syntax errors, cant convert void to bool
Do you know how to solve my problem?
Regards
how to get true or false from validation
Re: how to get true or false from validation
i have tried in such way
if(textSearchable=="y" && Validate.Attribute(repo.smthInfo, "Checked","True","",true)==true){
Report.Log(ReportLevel.Info, "Yes");
}
else {
Report.Log(ReportLevel.Info, "No");
}
but in first validation if validate.Attribute statement returns false my test fails on
at Ranorex.Validate.IsTrueInternal(Boolean condition, String message, Options options, RepoItemInfo itemInfo) at Ranorex.Validate.AttributeInternal(Element element, String name, Object value, String message, Options options, RepoItemInfo itemInfo) at Ranorex.Validate.Attribute(RepoItemInfo itemInfo, String name, Object value, String message, Options options) at Ranorex.Validate.Attribute(RepoItemInfo itemInfo, String name, Object value, String message, Boolean exceptionOnFail) at
if(textSearchable=="y" && Validate.Attribute(repo.smthInfo, "Checked","True","",true)==true){
Report.Log(ReportLevel.Info, "Yes");
}
else {
Report.Log(ReportLevel.Info, "No");
}
but in first validation if validate.Attribute statement returns false my test fails on
at Ranorex.Validate.IsTrueInternal(Boolean condition, String message, Options options, RepoItemInfo itemInfo) at Ranorex.Validate.AttributeInternal(Element element, String name, Object value, String message, Options options, RepoItemInfo itemInfo) at Ranorex.Validate.Attribute(RepoItemInfo itemInfo, String name, Object value, String message, Options options) at Ranorex.Validate.Attribute(RepoItemInfo itemInfo, String name, Object value, String message, Boolean exceptionOnFail) at
Re: how to get true or false from validation
Validate.Attribute() returns void (Which you found out). I'm pretty sure if the validation fails on the object it'll break the current case and report it on the log.
Instead of using validation use something like
Instead of using validation use something like
Code: Select all
if(textSearchable=="y" && repo.smth.Checked==TRUE){
//do this
}
else {
//this
}
Re: how to get true or false from validation
you are right if validation fails it is breaking my test. So my solution was to use this:
now if it fails it is just reporting on Info level
Code: Select all
Validate.Options option = new Validate.Options(ReportLevel.Info);
option.ExceptionOnFail=false;
if(textSearchable=="y" && Validate.Attribute(repo.smthInfo, "Checked","True","",option)){
do smth
}
Re: how to get true or false from validation
The Validation object should ONLY be used for validating something, not for logical comparison. It is not designed for that and could cause unwanted side-effects.
You should use the method outlined by Bat instead.
You should use the method outlined by Bat instead.
Shortcuts usually aren't...