How can I organize "IF ELSE" in Selenium IDE WITHOUT use extensions?
Just to conclude it for future readers:
The "right" and most complete way is to download a Flow Control plugin for Selenium IDE from the official page (aaaall the way down).
The most useful link I found is this one, because it has a complete example in it: http://selenium.10932.n7.nabble.com/if-else-statement-td4370.html
Anyway, there's also a documentation and author's blogpost explaining something more.
Without any Selenium IDE plugins (what a silly demand - Selenium IDE itself is a plugin!), there's nothing you can do besides writing the whole command in JavaScript. For this, the following functions may come in handy: document.getElementById(), document.getElementsByTagName(), document.getElementsByClassName(), document.querySelectorAll() and document.evaluate().
To use If..Else in selenium IDE, first add the plugin "SelBlock"/ link: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-sel-blocks/versions/. After that only you can able to use If..Else in your test case. Example:
<head>
<body>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>storeElementPresent</td>
<td>id=signin</td>
<td>test</td>
</tr>
<tr>
<td>echo</td>
<td>${test}</td>
<td></td>
</tr>
<tr>
<td>if</td>
<td>${test}==true</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=signin</td>
<td></td>
</tr>
<tr>
<td>else</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Logout')])[2]</td>
<td></td>
</tr>
<tr>
<td>endIf</td>
<td></td>
<td></td>
</tr>
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With