views:

698

answers:

1

I am trying to use cargo to deploy and start my container (which works fine), and then use selenium to execute some UI tests.

Whenever I try to run (mvn clean integration-test), I get to the point where it says

Launching Selenium Server
Waiting for Selenium Server...
[INFO]Redirecting output to
[INFO]User extensions

But then my integration tests never get executed by surefire. Any help is much appreciated. It seems like the Selenium Server never gets started.

One quick note, I am using JUnit 4.4

I tried using ANT instead, to copy over the selenium-server and start selenium that way. When I do that, my integration tests run, but I got the following error, which is why I was trying to use the selenium-maven-plugin.

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.3 sec <<< FAILURE!
testAllCriticalPagesLoadWithoutError(com.adminserver.pas.test.SimpleSmokeTest)  Time elapsed: 0.29 sec  <<< ERROR!
java.lang.RuntimeException: Could not start Selenium session: NUL
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89)
 at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:123)
 at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:104)
 at com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:78)
 at com.adminserver.pas.test.BaseSeleniumTest.setUp(BaseSeleniumTest.java:69)
 at com.adminserver.pas.test.SimpleSmokeTest.setUp(SimpleSmokeTest.java:22)
 at junit.framework.TestCase.runBare(TestCase.java:132)
 at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
 at junit.framework.TestResult$1.protect(TestResult.java:110)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.framework.TestResult.run(TestResult.java:113)
 at junit.framework.TestCase.run(TestCase.java:124)
 at junit.framework.TestSuite.runTest(TestSuite.java:232)
 at junit.framework.TestSuite.run(TestSuite.java:227)
 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
 at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
 at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
 at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
 at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
 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:585)
 at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
 at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

Here is the relevant snippets in my pom.xml

<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>selenium-maven-plugin</artifactId>
 <version>1.0</version>

 <executions>
  <execution>
  <id>start-selenium</id>
  <phase>pre-integration-test</phase>
  <goals>
   <goal>start-server</goal>
  </goals>
 </execution>
 </executions>
 <configuration>
  <timeout>30</timeout>
  <background>true</background>
  <port>4444</port>
  <logOutput>true</logOutput>
  <verifyBrowser>*iexplore</verifyBrowser>
 </configuration>
 </plugin>
 <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.4.2</version>
  <configuration>
  <skip>true</skip>
  <testFailureIgnore>true</testFailureIgnore>     
  </configuration>
  <executions>
   <execution>
    <phase>integration-test</phase>
    <goals>
     <goal>test</goal>
    </goals>
    <configuration>
     <skip>false</skip>
    </configuration>
   </execution>
  </executions>
  </plugin>

Here is the output from the selenium server.log file:

11:35:51,542 INFO  [org.openqa.selenium.server.SeleniumServer] Java: Sun Microsystems Inc. 1.5.0_19-b02
11:35:51,542 INFO  [org.openqa.selenium.server.SeleniumServer] OS: Windows 2003 5.2 x86
11:35:51,592 INFO  [org.openqa.selenium.server.SeleniumServer] v1.0.1 [2697], with Core v@VERSION@ [@REVISION@]
11:35:51,712 INFO  [org.mortbay.http.HttpServer] Version Jetty/5.1.x
11:35:51,712 INFO  [org.mortbay.util.Container] Started HttpContext[/,/]
11:35:51,722 INFO  [org.mortbay.util.Container] Started HttpContext[/selenium-server,/selenium-server]
11:35:51,722 INFO  [org.mortbay.util.Container] Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:35:51,732 INFO  [org.mortbay.http.SocketListener] Started SocketListener on 0.0.0.0:4444
11:35:51,732 INFO  [org.mortbay.util.Container] Started org.mortbay.jetty.Server@bf32c
+3  A: 

I got this finally to work. Here are a couple of things that made this work:

  1. JBOSS in the default startup started up its RMI Port on 4444 (that's the same one as Selenium ). Not sure why I this wasn't more blatant obvious, maybe the sequence of runs in the maven file. I added a port to the selenium-maven-plugin configuration, and added a system property of selenim.port to the surefire-plugin, PRESTO, it worked.

  2. My plugin repository for Codehause (which publishes the selenium-maven-plugin) was set to snapshots (DOH). I changed it to the release repo, that seemed to get things moving.

  3. I changed the type of the project to "pom", so it didn't attempt to create a JAR

  4. I don't know if it mattered or not, but I moved the surefire plugin to be AFTER the selenium-maven-plugin

noplay
Thanks for posting your solution to your problem (especially the port conflict between selenium and JBoss, highly valuable)
Pascal Thivent