0

I need to add a date comparison test to my selenium tests. Are there any restrictions when it comes to adding JavaScript within the tests? In my case I have the date form like this "2011-01-01 15:30" and I need to break out the numbers to do a JavaScript date like this new Date(2011,1,1,15,30).

<tr>
<td>open</td>
<td>http://www.google.com/search?hl=en&amp;q=selenium+verifyEval</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>//p[@id='resultStats']/b[3]</td>
<td>resultCount</td>
</tr>
<tr>
<td>storeEval</td>
<td>//here I would put in the javascript to parse the two strings "2010-01-01 13:15", "2010-01-02 11:15" to a new Date(2010,1,1,13,15),new Date(2010,1,2,11,15) and return a bool if true or false</td>
<td>isDateEqual</td>
</tr>
<tr>
<td>verifyExpression</td>
<td>${isDateEqual}</td>
<td>true</td>
</tr>

1 Answer 1

1

Nope, that ought to work fine. Except, of course, that JavaScript's brain-damaged Date() thinks that months (and only months) run from 0 to 11.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.