I just started looking into selenium for automated testing for the past few days and am getting pretty stuck. I've been looking for documentation on this but haven't found anything very helpful but maybe one of you have found something interesting, if so I'd love to read it.
Anyway, here's the problem: I need to open up a website. This website takes in some parameters which takes the browser to another site, however if the parameters are invalid then the next site will display a message saying "An error has occurred".
If the second site doesn't error out like this we want to store a few arbitrary values and echo them later. If the site does error out we want to mark the error and move on. Right now, if the second site is invalid selenium stops running.
The only way it seems to do this is to have an if-else statement though I haven't found any mention of one in selenium. I have read somewhere that you can create some javascript on your own and then input that into selenium. The problem there is that I don't know how to actually input the javascript into selenium.
I hope that wasn't too confusing.
Thank you,
Jesse Smothermon
You can use conditional statements in your code to do this. With if/elseif/else/end you use if to specify a block of code to be executed, if a specified condition is true and use else to specify a block of code to be executed, if the same condition is false.
Selenium IDE comes with commands that enable you to add conditional logic and looping to your tests. This enables you to execute commands (or a set of commands) only when certain conditions in your application are met, or execute command(s) repeatedly based on pre-defined criteria.
Verify in Selenium (also known as Soft Assertion) In a hard assertion, when the assertion fails, it terminates or aborts the test. If the tester does not want to terminate the script they cannot use hard assertions. To overcome this, one can use soft assertions.
My coworker found it. code below:
<tr>
<td>storeEval</td>
<td>(selenium.isElementPresent("variable_looked_at")?selenium.getText("variable_looked_at"):"N/A")</td>
<td>Address</td>
</tr>
Thanks,
Jesse Smothermon
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