6

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

3
  • Programming languages have support for conditionals? Is that what you mean? Commented Jun 24, 2011 at 22:05
  • I think you are able to use Java or C# etc. to program the conditional statements. The plan would be that I could code a simple if-else statement in Java and then have it run in Selenium. Is that possible? Commented Jun 24, 2011 at 22:13
  • Yes this is possible. You need to use Selenium RC for this Commented Jun 25, 2011 at 14:12

3 Answers 3

7

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

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

Comments

1

I am fairly new to selenium too, but I think what you want to do is use the Selenium IDE and export to visual studio or something. When you use selenium with visual studio (C#) you have complete control over the flow of the test. its much more easier to program something like that. but at the same time, you need to configure it with Nunit or selenium RC.

Also out there is a selenium extension called "Flow Control". I have not used it, but I believe it will allow the Selenium IDE to do if/else/etc

Comments

0

As a unit test, if the second site has failed, the unit test has failed. Perhaps rather than looking for a conditional processing of your unit test, fix the problem that causes the test to fail.

That may sound a little harsh and forgive me if it does, but it sounds illogical to me that you would want to take this approach.

2 Comments

The only reason why I'm taking this approach is because my boss wants me to. Our overall goal is to run the selenium for roughly ten minutes and test a variety of inputs. Mainly we want to see if valid parameters are outputted correctly and if invalid parameters are outputted correctly. This way we could run the program on say, 50 parameters and return an error report of saying all the ones that failed. Thanks for the reply
Personally, I would consider each of those scenarios as a Unit Test in itself and code them accordingly.

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.