With javascript make Selenium test fail
Is there a way for js code to force disable Selenium testing? For a (possibly bad) example, if I had the following:
return document.getElementById('foo').innerHTML == 'hello'
Is there a way that the "runScript" command can fail depending on whether the js code returned true or false? (I know this example can be used by other Selenium commands, but I wanted a more general solution.)
I need to learn how to extend Selenium to add another command?
I'm also relatively new to Selenium, so is this what Selenium-rc will solve?
a source to share
assertExpression
will give you what you ask for.
For example, the following line will cause your test to fail if the specified JavaScript expression is not true.
<tr>
<td>assertExpression</td>
<td>javascript{this.browserbot.getCurrentWindow().document.getElementById('foo').innerHTML == 'hello'}</td>
<td>true</td>
</tr>
a source to share
It depends on how you want to use selenium. The Selenian suite has calls to verifyText, etc. (Just google for the selenese suite and verifyText, waitForCondition). If you are using selenium remote control in for example java than you are making statements in Java code. With the remote, you send scripts to the page, and you return what the code-behind returns. The mapping / assertion is done in the java client.
a source to share