grails + selenium-rc 插件 - 无法运行示例测试

标签 grails selenium

我不知道我做错了什么。我想使用 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 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 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

Firefox 窗口已打开,但没有加载任何内容,似乎没有任何进展。我错过了什么吗?

最佳答案

在我看来,Selenium RC 插件和当前版本的 Web 浏览器之间不兼容。如果您使用的是较新版本的浏览器,您可能需要深入了解插件的依赖项并将所有内容更新到最新版本。

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

关于grails + selenium-rc 插件 - 无法运行示例测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8369916/

相关文章:

grails - 如何获取gsp页面中选定单选按钮的id值以使 Controller /域类

java - 如何使用java在selenium中关闭Windows警报框后切换到主窗口

java - 强制一个线程使用的映射中的元素不应被另一个线程使用,直到第一个线程完成执行

java - Javascript 完成后开始 Selenium 测试

java - 如何单击链接列表中随机生成的链接

gradle - Grails 3排除类(class)

java - 如何管理跨多个项目的共享引导数据

hibernate - 没有生成外键

jquery - 如何将JSON渲染为jQuery

javascript - 无法找到要单击的元素/使用 Java 在 selenium 中发送 key