[rc] Problem migrating Selenium 1 RC Test Suite To use Selenium 2 WebDriver-backed Selenium

82 views
Skip to first unread message

Graeme

unread,
Jan 11, 2011, 6:11:00 AM1/11/11
to Selenium Users
Hi

I have a set of Selenium 1 RC Java-based functional tests [against a
Web application developed internally in my organisation.]

I want to migrate the suite to run against Selenium 2 using WebDriver-
backed Selenium. In my original Selenium 1 RC Test Suite my tests
operated as as follows [driven from maven 2 using failsafe plugin for
integration testing]

1) Start Selenium server

BeforeClass Setup for Test1
Run JUnit 4 test methods in Test1
AfterClass Tear Down for Test1

BeforeClass Setup for Test 2
Run JUnit 4 test methods in Test2
AfterClass Tear Down for Test1

<SNIP>...

BeforeClass Setup for Test N
Run JUnit 4 test methods in Test N
AfterClass Tear Down for Test N

N+1) Stop selenium server

Now in my first attempt to migrate to Selenium 2 WebDriver-backed
Selenium my Test 1 completes fine,
but Tests 2 thru N all end with an error exception stack like ...

Tests run: 23, Failures: 0, Errors: 20, Skipped: 0, Time elapsed:
24.232 sec <<< FAILURE!
com.bt.collaborate.dso.storm.regression.story.create.ITStoryCreateTest
Time elapsed: 3.5 sec <<< ERROR!
java.lang.IllegalStateException: Timer already cancelled.
at java.util.Timer.sched(Timer.java:354)
at java.util.Timer.schedule(Timer.java:170)
at
org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:
37)
at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:
279)
at
org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:
211)
at
com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:
353)
at
com.bt.collaborate.dso.storm.regression.AbstractSeleniumTest.login(AbstractSeleniumTest.java:
40)
at
com.bt.collaborate.dso.storm.regression.AbstractSeleniumTest.setUp(AbstractSeleniumTest.java:
21)
at
com.bt.collaborate.dso.storm.regression.story.create.ITStoryCreateTest.setUp(ITStoryCreateTest.java:
23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runners.Suite.runChild(Suite.java:117)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:
59)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:
115)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
102)
at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:
350)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:
1021)

In my Selenium 2 approach, the steps involving the starting and
stopping of the RC server disappear.

In my BeforeClass Setup for Test i [i = 1,2,...,N]
I create a WebDriver backed Selenium instance, like this

public static DefaultSelenium selenium ;
public static WebDriver driver;

driver = new FireFoxDriver();
selenium = new WebDriverBackedSelenium(driver, "URL of Web App under
test");

login to web app under test etc.

In my My AfterClass TearDown for Test i,
a) logout of the Web App under Test
b) stop Selenium with

selenium.stop();

This arrangement only works for the first test in the Test Suite. I
suspect I need different
approach in in my AfterClass TearDown to be able run all the tests in
the suite successfully.
I have not seen this aspect discussed for Selenium 2 WebDriver-backed
Selenium.

Can someone please point me in the right direction here ?

Thanks
-Graeme, UK

I basically create a WebDriver backed Selenium instance with

Sergii

unread,
Jan 11, 2011, 11:22:55 AM1/11/11
to seleniu...@googlegroups.com
Try to use driver.quit() instead of selenium.stop()

> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages