我正在尝试通过Selenium-RC插件在我的Grails项目中设置Selenium。然后,我运行了grails install-plugin selenium-rc命令。
然后,我运行了grails create-selenium-test firstTest命令,并在其中添加了以下内容:
import grails.plugins.selenium.*
import org.junit.*
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
@Mixin(SeleniumAware)
class FirstTestTests {
@Before void setUp() {
}
@After void tearDown() {
super.tearDown()
}
@Test void something() {
selenium.open "/"
assertTrue selenium.isTextPresent("Bem vindos")
}
}当我在Ubuntu 11.04上运行测试时,Grails启动了默认的firefox浏览器(8.0版),但在将以下内容打印到控制台输出后在此处冻结:
Server running. Browse to http://localhost:8080/
[groovyc] Compiling 1 source file to /home/alessandro/Documents/[...]/target/test-classes/selenium
Starting Selenium server on port 4444 ...
Starting Selenium session for http://www.mywebsite.com/ ...当我通过Ctrl + C中断测试时,它抛出以下错误消息:
Error running selenium tests: java.lang.RuntimeException: Could not contact Selenium Server; have you started it on 'localhost:4444' ?
Read more at http://seleniumhq.org/projects/remote-control/not-started.html
Connection refused
java.lang.RuntimeException: Could not contact Selenium Server; have you started it on 'localhost:4444' ?
Read more at http://seleniumhq.org/projects/remote-control/not-started.html
Connection refused
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:86)
at com.thoughtworks.selenium.Selenium$start$0.call(Unknown Source)
at grails.plugins.selenium.SeleniumWrapper.start(SeleniumWrapper.groovy:90)
at com.thoughtworks.selenium.Selenium$start.call(Unknown Source)
at grails.plugins.selenium.SeleniumRunner.startSelenium(SeleniumRunner.groovy:35)
at grails.plugins.selenium.SeleniumRunner$startSelenium.call(Unknown Source)
at _Selenium_groovy$_run_closure2.doCall(_Selenium_groovy:50)
at _Events$_run_closure3.doCall(_Events.groovy:32)
at _GrailsEvents_groovy$_run_closure5.doCall(_GrailsEvents_groovy:58)
at _GrailsEvents_groovy$_run_closure5.call(_GrailsEvents_groovy)
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:265)
at _GrailsTest_groovy$_run_closure4.call(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:228)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:187)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:174)
at TestApp$_run_closure1.doCall(TestApp.groovy:82)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)我已经阅读了插件文档,其中说服务器是由插件启动的,在测试冻结之前,它由控制台输出作为支持。我真的不知道下一步该怎么做。我浏览过网页,但我找到的唯一一条建议是将selenium-server.jar添加到java path中,这似乎已经被插件覆盖了。
非常感谢您的帮助。
发布于 2011-12-08 01:21:19
我也有同样的问题--你可以看看我的question。我猜问题出在火狐上--我把它改成了Chrome,它开箱即用。你只需要替换掉
browser = "*firefox"使用
browser = "*googlechrome" 在SeleniumConfig中
发布于 2011-12-08 02:42:56
非常感谢。它就像你说的那样有效。对于那些在Ubuntu下也使用Chromium的用户,下面是我添加来配置SeleniumConfig文件的内容:
browser = "*googlechrome /usr/lib/chromium-browser/chromium-browser"现在我明白了:
Stopping Selenium server ...
java.lang.RuntimeException: Can't start SslRelay: server is not started (perhaps it was just shut down?)
at org.openqa.selenium.server.ProxyHandler.getSslRelayOrCreateNew(ProxyHandler.java:656)
at org.openqa.selenium.server.ProxyHandler.handleConnect(ProxyHandler.java:589)
at org.openqa.selenium.server.ProxyHandler.handle(ProxyHandler.java:274)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:245)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)当测试通过后。我会调查一下的。感谢mkk
https://stackoverflow.com/questions/8403761
复制相似问题