Fighting with Grails 1.3.x,Webtest 3.0.0 and jQuery?
I'm guessing the reason you are here is because you are trying to get Webtest 3.0.0 to work with Grails 1.3.x and you are having no luck.
I'm guessing your day started as follows :
Either you, or someone in your office decided that your grails project requires Functional testing (Good call!).
The entire programming team agrees that this is a great decision and you get assigned to go about investigating Functional testing for grails. (grails does not natively support functional testing).
Some how (either via google or by some other magical means) you have come across Canoo's Webtest. You read about it, you see the screenshots, and you think to yourself.. mmmm.. This is perfect, does grails have a plugin for this? Again, you google and you find the following page http://www.grails.org/plugin/webtest
Instructions look simple enough.. You follow the instructions carefully, everything is ready to rock 'n roll.
You create a simple little webtest to test the waters, off you go running your first test using the command "test-app functional:webtest"
Suddenly horrible red expections are being thrown all over the place.. You read it, and it says something about javascript and a "createComment()" function.. You are like WTF mate?
Sound about right?
Okay, enough dorkieness.. Here is the problem.
When grails installs Webtest it also install HtmlUtils, but it installs HtmlUtils 2.4 (which is like 2years old [don't ask me why]).
HtmlUtils 2.4 has a bug that crashes if you have jQuery running. So pretty much all you have to do is update your HtmlUtils dependency.
How do you do that you ask? Good question!
Easy!
First goto your Projects Plugin Directory
documents and settings\your folder\.grails\1.3.5\projects\project_name\plugins
You should see a webtest-3.0.0 folder (if you don't, you've screwed something else up, read the Grails instructions again)
Open the folder and then open a file called : dependencies.groovy
dependencies.groovy informs grails what else is needed for this plugin to work properly. (We need to tell grails that we require HtmlUnit 2.5, cause 2.4 which is coupled with Webtest 3.0.0 is broken..)
So we change our dependencies to look as follows :
dependencies {
test('net.sourceforge.htmlunit:htmlunit:2.5') {
excludes 'xalan'
excludes 'xml-apis'
}
test('com.canoo.webtest:webtest:3.0') {
excludes 'xalan' // IVY-1006 - use xalan 2.7.0 to avoid (see below)
excludes 'xml-apis' // GROOVY-3356
}
test('xalan:xalan:2.7.0') {
excludes 'xml-apis' // GROOVY-3356
}
}
Note : I know that there are HtmlUnit versions greater that 2.5.. But so far I've only gotten 2.5 to work.. Anything higher and it starts conflicting with other Webtest classes and things get really messy from there on out..
I hope this saves you all a ton of time (an entire day to be exact!)
Happy Functional testing!!
Ever tried to setup a linux server – window client git environment and failed?
I've just completed a step-by-step guide on how to setup a Linux Server Window Client git environment for anyone who has ever struggled with this sort of thing..
I left no stone unturned when I published the most direct and easiest Git and SSH tutorial ever!
Setting up a Linux Server - Window Client Git Environment/
(Also found under my Grails Section)
Enjoy :D
Grails.. The Low down
Long story short.
I'm busy learning grails. This obviously has some learning curve to it and requires some screwing around as well as learning Groovy and Spring.
Good news is, I'll be documenting most of my stresses and trials (seeing as I can't find anyone else doing it) so that if you decide to jump aboard the Grails boat you don't have to stare at your screen for hours going "WTF MATE"....
The parent post will be listing all the topics I'll be covering.
To date I've covered :
What is Grails? and
Grails + Spring Security + MySQL installation
Enjoy & happy coding