Page 1 of 1

Change the reporting level of Validate.Attribute false?

Posted: Tue Dec 11, 2012 10:51 pm
by jvance
Is ther any way to force a Validate.Attribute failure into a warning?

Here's what I'm using it for. I need to click a specific object depending on how a screen is rendered. All the objects in question Exist (which is why I can't use Validate.Exist) but they are visible or not, depending on what screen I'm on.

I'm validating the visible attribute is true in order to figure out what screen was rendered and click the button.

if (validate.Attribute(repo.button1, "Visible", "True", "message", false) == true){
click button1
}else if(validate.Attribute(repo.button2, "Visible", "True", "message", false) == true){
click button 2
}
else {do something else...}

So if I'm on the screen with button 1 then my script will pass but if i'm on the screen with button 2 the validation looking for button1 will fail which causes the entire test to fail.

Is there a way to change the reporting level for that particular validation statement to a warning so the step doesn't fail? Or else, Is there any way I can force the test case to Pass?

There might be another way to approach this that I'm not thinking of....
Thanks

Re: Change the reporting level of Validate.Attribute false?

Posted: Wed Dec 12, 2012 12:03 am
by Ciege
How about just changing it to your own little if else statement...

Code: Select all

if (repo.button1.visible ==  true)
{
click button1
}
else if(repo.button2.visible == true)
{
click button 2
}

Re: Change the reporting level of Validate.Attribute false?

Posted: Wed Dec 12, 2012 10:55 am
by Support Team
Hi,

Thanks Ciege for this solution.
I additionally wanted to say that it is of course possible to change the ReportLevel of the Validation method. This can be done with the Validate.Options class, the class enables you to specify the ReportLevel for the specific Validation method.
For detailed information please take a look at our online API: Validate.Attribute.

Regards,
Markus

Re: Change the reporting level of Validate.Attribute false?

Posted: Wed Dec 12, 2012 4:05 pm
by jvance
Hi Ciege, I thought that's what I was doing by validating the object was visible in my code. Is there another methode I can call from the repo object called "Visible"? I'm not seeing it - only "UseEnsureVisible" which I don't want.

Markus, the Validate statement I'd like to use is
Attribute(RepoItemInfo, String, Object, String, Validate.Options)
where Validate.Options = "Validate.Options(Boolean, ReportLevel)"
but the compiler is throwing an error and trying to force Attribute(RepoItemInfo, String, Object, String, Boolean)

My code:
Attempt 1:
Validate.Attribute(repo.button1, "Visible", "True","Check Object '{0}'", false, ReportLevel.Info)
=>compiler error: "No overload for method 'Attribute' takes 6 arguments (CS1501)"

Attempt 2:
Validate.Attribute(repo.button1, "Visible", "True","Check Object '{0}'", false, ReportLevel.Info)
=> compiler errors: "Argument 5: cannot convert from 'Ranorex.ReportLevel' to 'bool' (CS1503)" and
"The best overloaded method match for 'Ranorex.Validate.Attribute(Ranorex.Core.Repository.RepoItemInfo, string, object, string, bool)' has some invalid arguments"

Thanks for the help
-J

Re: Change the reporting level of Validate.Attribute false?

Posted: Wed Dec 12, 2012 4:13 pm
by Ciege
jvance wrote:Hi Ciege, I thought that's what I was doing by validating the object was visible in my code. Is there another methode I can call from the repo object called "Visible"? I'm not seeing it - only "UseEnsureVisible" which I don't want.
.visible should just be an attribute of your button element. You can directly grab that attribute value and test it yourself.

Re: Change the reporting level of Validate.Attribute false?

Posted: Wed Dec 12, 2012 6:31 pm
by jvance
Turns out I wasn't originally using a button object, which is why I couldn't see the Visible attribute. Once I looked for a button it worked perfectly. Thanks guys!

Re: Change the reporting level of Validate.Attribute false?

Posted: Wed Dec 12, 2012 6:35 pm
by Ciege
Great! Glad you got it working...