问题
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