Grails - functional test with Geb doesnt work with HtmlUnitDriver

六眼飞鱼酱① 提交于 2020-01-05 08:35:23

问题


I have created a functional test, which works fine when driver is FireFox or Chrome. The same fails when i try to use HtmlUnit driver. The application gets started, but gets stuck while running the first test. Then i have kill the java process to stop it.

Pasting the code snippet that i use to initialize the htmlunit driver

driver = {
  def driver = new HtmlUnitDriver()
  driver.javascriptEnabled = true
  baseUrl = 'http://localhost:8585'
  driver  }

回答1:


Which version of grails are you using? HTMLUnit is broken with grails 2.2 onwards.

We've had lots of pains with it, and ditched it for phantomJS which works beautifully, we only had to make some minor tweaks to some tests.

Tomás Lin has a great post on how to configure phantomJS for Geb, as well as many other web drivers:

http://fbflex.wordpress.com/2013/03/18/how-to-configure-webdriver-in-grails-for-your-geb-tests/

edit: you may have to add the path to the phantomJS binary:

System.setProperty('phantomjs.binary.path', phantomJs.absolutePath)


来源:https://stackoverflow.com/questions/20095893/grails-functional-test-with-geb-doesnt-work-with-htmlunitdriver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!