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
Change the reporting level of Validate.Attribute false?
Re: Change the reporting level of Validate.Attribute false?
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...
Ciege...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Change the reporting level of Validate.Attribute false?
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
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?
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
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?
.visible should just be an attribute of your button element. You can directly grab that attribute value and test it yourself.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.
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...
Ciege...
Re: Change the reporting level of Validate.Attribute false?
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?
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...
Ciege...