Unable to get Selenium / JUnit test to run in eclipse -- Special Characters error happening at random

27 views
Skip to first unread message

jasonAdsafeMedia

unread,
Sep 26, 2011, 4:55:06 PM9/26/11
to Selenium Users
I figured I would shoot in the dark and try to ask you about an issue
I am having converting selenium tests into JUnit tests.

I keep getting a random error happening on a specific line of code.
When I take this line of code and move it higher up in my selenium
test it works fine. I am not sure at all why its failing.


There error I am getting is this:

com.thoughtworks.selenium.SeleniumException: ERROR: There was an
unexpected Alert! [Special characters are not allowed. Only alpha
numeric charactor allowed]
at
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:
101)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:
95)
at
com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:
343)
at
com.media6.qa.TestCreateMarketer.testCreateMarketer(TestCreateMarketer.java:
45)


The line in question is this

selenium.click("name=submit");selenium.open("/orbadmin/marketers.mvc?
method=getView");


If I take this line and put it at the beginning of my selenium/junit
test it runs just fine. Makes no sense!!??

Any feedback you could give would be awesome.

Ross Patterson

unread,
Sep 27, 2011, 8:58:25 AM9/27/11
to seleniu...@googlegroups.com
One observation: your code clicks on what I'm guessing is a form's submit button, and then immediately loads a new page. Depending on timing-related events, it's a little unpredictable what exactly will happen. I expect you want the form to be submitted before you open the next page, but it might not have been. You should at least call waitForPageToLoad() between the two.

FYI, the specific error is a unexpected JavaScript alert. Selenium catches those and waits to see if the next thing your script does is ask for it (via getAlert()). If not, you get the error. So the alert was produced by your application during the *previous* Selenium command.

Ross

Reply all
Reply to author
Forward
0 new messages