Dustin N.
Dustin N.

Reputation: 795

Selenium IDE - AssertEval 2 Numbers, As Long As They Are Within 5 Either Way

I'm doing an AssertEval on 2 numbers and as long as they are the exact same, it passes. My issue is that the numbers can be within 5 of each other, either way. Currently, if they don't match, the script fails.

I'm very new at javascript. Can somebody please show me how I would handle this?

Example: Num1 = 20

Num2 can be anywhere from 15 - 25 to still pass the Eval.

Upvotes: 0

Views: 732

Answers (1)

DMart
DMart

Reputation: 2461

Here you go. This is the javascript that does the check of +/- 5. then compares the output using an assertEval

<tr>
<td>assertEval</td>
<td>var num1=20; var num2=19;&nbsp;&nbsp;&nbsp;( (num1 + 5) &gt; num2) &amp;&amp; ( (num1 - 5) &lt; num2);</td>
<td>true</td>
</tr>

Upvotes: 1

Related Questions