2011-12-03 32 views
2

我不知道我做错了什么。我想用Grails的selenium-RC插件做一些功能测试。grails + selenium-rc插件 - 无法运行样本测试

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 "/activate" 
    assertTrue selenium.isTextPresent("activate") 
    } 
} 

我配置SeleniumConfig

硒{

slow = false         // true to run tests in slow resources mode 
    singleWindow = true        // true for single window mode, false for multi-window mode 
    browser = "*firefox"       // can include full path to executable, default value is *firefox or *iexplore on Windows 
    url = "http://localhost:8080"          // the base URL for tests, defaults to Grails server url 
    defaultTimeout = 3000       // the timeout after which selenium commands will fail 
    windowMaximize = true      // true to maximize browser on startup 
    screenshot { 
    dir = "./target/test-reports/screenshots" // directory where screenshots are placed relative to project root 
    onFail = true       // true to capture screenshots on test failures 
    } 
    server { 
    host = "localhost"       // the host the selenium server will run on 
    port = 4444         // the port the selenium server will run on 
    } 
    userExtensions = ""        // path to user extensions javascript file 

} 
:我已使用建立的脚本(我想添加硒检验),这产生(ⅰ改性它略低)创建的样本测试

和我然后我输入

grails test-app :selenium 

,似乎一切都做得正确:

INFO 19:30:08,304 RemoteWebDriver instances should connect to: http://127.0.0.1: 
4444/wd/hub org.openqa.selenium.server.SeleniumServer 
Starting Selenium server on port 4444 ... 
INFO 19:30:08,312 Version Jetty/5.1.x org.openqa.jetty.http.HttpServer 
INFO 19:30:08,315 Started HttpContext[/selenium-server/driver,/selenium-server/d 
river] org.openqa.jetty.util.Container 
INFO 19:30:08,318 Started HttpContext[/selenium-server,/selenium-server] org.ope 
nqa.jetty.util.Container 
INFO 19:30:08,321 Started HttpContext[/,/] org.openqa.jetty.util.Container 
INFO 19:30:08,326 Started [email protected] 
org.openqa.jetty.util.Container 
INFO 19:30:08,328 Started HttpContext[/wd,/wd] org.openqa.jetty.util.Container 
INFO 19:30:08,338 Started SocketListener on 0.0.0.0:4444 org.openqa.jetty.http.S 
ocketListener 
INFO 19:30:08,340 Started [email protected] org.openqa.jett 
y.util.Container 
Starting Selenium session for http://localhost:8080 ... 
INFO 19:30:08,502 Checking Resource aliases org.openqa.jetty.util.Credential 
INFO 19:30:08,510 Command request: getNewBrowserSession[*firefox, http://localho 
st:8080, ] on session null org.openqa.selenium.server.SeleniumDriverResourceHand 
ler 
INFO 19:30:08,512 creating new remote session org.openqa.selenium.server.Browser 
SessionFactory 
INFO 19:30:08,586 Allocated session 9250557308cc4886a25100eb6c5f3d7e for http:// 
localhost:8080, launching... org.openqa.selenium.server.BrowserSessionFactory 
INFO 19:30:08,717 Preparing Firefox profile... org.openqa.selenium.server.browse 
rlaunchers.FirefoxChromeLauncher 
INFO 19:30:11,726 Launching Firefox... org.openqa.selenium.server.browserlaunche 
rs.FirefoxChromeLauncher 

firefox窗口打开,但没有加载,似乎没有任何进展。我想念什么?

回答

1

听起来像Selenium RC插件和当前版本的Web浏览器之间的不兼容。如果您使用更新版本的浏览器,您可能需要深入了解插件的依赖关系,并将所有内容更新为最新版本。

当试图运行与驱动程序版本不兼容的网络驱动程序版本时,我们在Geb(http://www.gebish.org)中看到了这一点。

+0

谢谢托马斯一个想法 - 我会尽量 – mkk

+0

你是男人改变浏览器!谢谢,我改变了铬,它的工作'开箱':) – mkk

0

我想补充,如果你使用Chrome浏览器与操作系统是Ubuntu的,然后确保你把完整路径Chrome浏览器并确保该可执行文件路径引用铬浏览器谷歌铬。

所以你SeleniumConfig应该像这样与相关线双星号:

selenium { 

    slow = false 
    singleWindow = true 
    **browser = "*googlechrome /usr/bin/chromium-browser"** 
    url = null 
     defaultTimeout = 60000 
    windowMaximize = false 
    screenshot { 
     dir = "./target/test-reports/screenshots" 
     onFail = false 
    } 
    server { 
     host = "localhost" 
     port = 4444 
    } 
    userExtensions = "" 
} 
+0

更新:这取决于你的Linux发行版的铬。如果你有谷歌浏览器,那么它被称为谷歌浏览器,否则你有Ubuntu打包铬,在这种情况下,它是铬浏览器。详情请参阅http://code.google.com/p/chromium/wiki/ChromiumBrowserVsGoogleChrome – Tone