Change the reporting level of Validate.Attribute false?

Class library usage, coding and language questions.
jvance
Posts: 4
Joined: Tue Dec 11, 2012 10:38 pm

Change the reporting level of Validate.Attribute false?

Post by jvance » Tue Dec 11, 2012 10:51 pm

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

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

Post by Ciege » Wed Dec 12, 2012 12:03 am

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
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Wed Dec 12, 2012 10:55 am

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
.
Image

jvance
Posts: 4
Joined: Tue Dec 11, 2012 10:38 pm

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

Post by jvance » Wed Dec 12, 2012 4:05 pm

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

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

Post by Ciege » Wed Dec 12, 2012 4:13 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

jvance
Posts: 4
Joined: Tue Dec 11, 2012 10:38 pm

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

Post by jvance » Wed Dec 12, 2012 6:31 pm

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!

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

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

Post by Ciege » Wed Dec 12, 2012 6:35 pm

Great! Glad you got it working...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...