Hi Support,
We would need a method to validate the actual/expected values to be within a range/offset. The code for this is attached. Could you guide us on how to create this a Custom Validate Actions' Method?.
The expectation is that a Validation would be compared for 2 Values(actual, expected) to be within a bound(+/- Offset).
public bool testEqual(int expected, int actual, int offset)
{
if (Math.Abs(actual - expected)< offset)
{
Console.WriteLine("value is within Bounds");
return true;
}
else
{
Console.WriteLine("value is out of Bounds");
return false;
}
}
Create Custom Validation Attribute instead of AttributeEqual
-
- Posts: 15
- Joined: Tue Mar 15, 2016 12:16 pm
Re: Create Custom Validation Attribute instead of AttributeEqual
Hi,
I'm not quite sure what exactly you want to achieve? The method you posted is basically all you need to use it as a custom validation method. In recording module, add new User Code action and simply add the content of your method to just created User Code action. To record success or failure in report, use Report.Success or Report.Failure methods (described here). To make the test to fail (in case of failed comparison) you can use Validate.Fail(string) method instead of Report.Failure. Hope this helps?
I'm not quite sure what exactly you want to achieve? The method you posted is basically all you need to use it as a custom validation method. In recording module, add new User Code action and simply add the content of your method to just created User Code action. To record success or failure in report, use Report.Success or Report.Failure methods (described here). To make the test to fail (in case of failed comparison) you can use Validate.Fail(string) method instead of Report.Failure. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
- Posts: 15
- Joined: Tue Mar 15, 2016 12:16 pm
Re: Create Custom Validation Attribute instead of AttributeEqual
Thank you Support.
The information helps. what was not clear was the ability to Pick additional attributes for the Object from the repository
The information helps. what was not clear was the ability to Pick additional attributes for the Object from the repository