grails + selenium-rc插件 - 无法运行样本测试 [英] grails + selenium-rc plugin - cannot run sample test

查看:125
本文介绍了grails + selenium-rc插件 - 无法运行样本测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我做错了什么。我想用Grails的selenium-RC插件做一些功能测试。我已经使用内置脚本创建了示例测试(我猜是add-selenium-test),它生成了(我修改了它略有不同):

  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



selenium {

  slow = false // true在慢资源模式下运行测试
singleWindow = true //对于单窗口模式为true,对于多窗口模式为false
browser =* firefox//可以包含完整可执行文件的路径,缺省值是Windows上的* firefox或* iexplore
url =http:// localhost:8080//测试的基本URL,默认为Grails服务器url
defaultTimeout = 3000 / /超时之后selenium命令将失败
windowMaximize = true // true在启动时最大化浏览器
截图{
dir =./target/test-reports/screenshots// directory截图相对于项目根目录
onFail = true // true截取测试失败截图
}
服务器{
host =localhost//主机selenium服务器将在
port = 4444上运行// selenium服务器将在
上运行的端口
userExtensions =//用户扩展的路径javascript文件

}

然后我输入

  grails test-app:selenium 

并且看起来一切正常:

  INFO 19:30:08,304 RemoteWebDriver实例应连接到:http://127.0.0.1:
4444 / wd / hub org.openqa.selenium.server.SeleniumServer
启动Selenium服务器端口4444 ...
INFO 19:30:08,312版本Jetty / 5.1.x org.openqa.jetty.http.HttpServer
INFO 19:30:08,315启动HttpContext [/ selenium-server / driver, / selenium-server / d
river] org.openqa.jetty.util.Container
INFO 19:30:08,318启动HttpContext [/ selenium-server,/ selenium-server] org.ope
nqa.jetty.util.Container
INFO 19:30:08,321启动HttpContext [/,/] org.openqa.jetty.util.Container
INFO 19:30:08,326启动org.openqa.jetty .jetty.servlet.ServletHandler @ 55881a8f
org.openqa.jetty.util.Container
INFO 19:30:08328开始的HttpContext [/ WD,/ WD] org.openqa.jetty.util.Container
INFO 1 9:30:08,338在0.0.0.0:4444上启动SocketListener org.openqa.jetty.http.S
ocketListener
INFO 19:30:08,340启动org.openqa.jetty.jetty.Server@42aefb01 org .openqa.jett
y.util.Container
为http:// localhost:8080 ...
启动Selenium会话INFO 19:30:08,502检查资源别名org.openqa.jetty。 util.Credential
INFO 19:30:08,510会话null上的命令请求:getNewBrowserSession [* firefox,http:// localho
st:8080,] org.openqa.selenium.server.SeleniumDriverResourceHand
LER
INFO 19:30:08512创建新的远程会话org.openqa.selenium.server.Browser
SessionFactory的
INFO 19:30:用于HTTP 08586分配会议9250557308cc4886a25100eb6c5f3d7e://
localhost:8080,启动... org.openqa.selenium.server.BrowserSessionFactory
INFO 19:30:08,717准备Firefox配置文件... org.openqa.selenium.server.browse
rlaunchers。 FirefoxChromeLauncher
INFO 19:30:11,726启动Firefox ... org.openqa.selenium.server.brow serlaunche
rs.FirefoxChromeLauncher

Firefox窗口已打开,但没有加载任何东西继续。我错过了什么?

解决方案

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

我们在Geb看到这个( http://www.gebish。 org )当试图运行与驱动程序版本不兼容的webdriver版本时。

I have no idea what I do wrong. I would like to use selenium-RC plugin for Grails to do some functional testing. I have created sample test using build-in script (i guess add-selenium-test), which generated (i modified it slighty):

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")
  }
}

I configured SeleniumConfig

selenium {

  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

}

and I then I typed

  grails test-app :selenium

and it seems that everything is done correctly:

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 org.openqa.jetty.jetty.servlet.ServletHandler@55881a8f
 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 org.openqa.jetty.jetty.Server@42aefb01 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

The firefox window is opened, but nothing loads and nothing seems to proceed. Do I miss something?

解决方案

Sounds to me like an incompatibility between the Selenium RC plugin and the current version of your web browser. You might want to dig into the plugin's dependencies and update everything to the latest versions if you're using a newer version of the browser.

We see this with Geb ( http://www.gebish.org ) when trying to run a webdriver version that is not compatible with the driver version.

这篇关于grails + selenium-rc插件 - 无法运行样本测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆