【发布时间】:2010-12-02 16:59:00
【问题描述】:
我正在尝试使用 cargo 来部署和启动我的容器(效果很好),然后使用 selenium 执行一些 UI 测试。
每当我尝试运行 (mvn clean integration-test) 时,我都会到达它所说的地方
Launching Selenium Server
Waiting for Selenium Server...
[INFO]Redirecting output to
[INFO]User extensions
但是我的集成测试永远不会被万无一失地执行。任何帮助深表感谢。 Selenium Server 似乎永远不会启动。
请注意,我使用的是 JUnit 4.4
我尝试使用 ANT 来复制 selenium-server 并以这种方式启动 selenium。当我这样做时,我的集成测试运行,但出现以下错误,这就是我尝试使用 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)
这是我的 pom.xml 中相关的 sn-ps
<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>
这是 selenium server.log 文件的输出:
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
【问题讨论】:
-
您的配置在我看来没问题,需要检查一些事项: IE 是否安装到非标准位置?如果使用命令行选项运行会看到什么:-Ddebug=true
-
硒依赖没有问题?
com.adminserver.pas.test.SimpleSmokeTest在你的 IDE 中运行良好吗? -
感谢您的反馈。我将检查 IE 安装并打开调试。帕斯卡,我不知道硒的依赖。似乎我从来没有得到“Selenium Server Started”,这是我所期望的;它只是挂起并且不会回来。当我在预集成测试中使用 ant 运行 selenium 服务器时,测试至少运行但失败了,我猜是因为我在运行它时分叉并产生了。它可能已经失败,因为服务器尚未启动。
-
IE 安装在 C:\Program Files\Internet Explorer
-
在调试模式下运行这个帮助不大...... ....... 17:57:13,614 INFO [org.openqa.selenium.server.SeleniumServer] Selenium 服务器在调试模式下运行。 17:57:13,755 INFO [org.mortbay.http.HttpServer] 版本 Jetty/5.1.x 17:57:13,755 INFO [org.mortbay.util.Container] 开始 HttpContext[/,/] 17:57:13,755 INFO [ org.mortbay.util.Container] 启动 HttpContext[/selenium-server,/selenium-server] .....
标签: maven-2 selenium maven-plugin