Grails Functional Testing: Uploading a file using G-Func plugin « Intelligrape Groovy & Grails Blogs

Grails Functional Testing: Uploading a file using G-Func plugin

Posted by

At Intelligrape we face many challenges while developing web-applications. One of the small challenge was to test the web pages that contains file input field <input type=”File”>(to upload files). After few hours drilling with Canoo webtest plugin I decided to use the new fabulous plugin, Grails functional Testing by Marc Palmer (http://www.grails.org/Grails+Functional+Testing).

The syntax for setting value for the file input field is

NameOfFileInputField.setValueAttribute("PathOfFileAsString")

Let me explain you with an example:
Following component’s HTML is

<input name="FileInputField" type="file" />

The name of the file input field is FileInputField.The code for setting value/path will be

FileInputField.setValueAttribute("testFile.txt")

any kind of suggestions and comments are welcome……

Cheers,
Chandan Luthra

www.IntelliGrape.com

This entry was posted on April 22nd, 2009 at 12:16 pm and is filed under Grails . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Grails Functional Testing: Uploading a file using G-Func plugin”

  1. Uday says:

    I was trying the method explained by Marc Parmer here http://www.anyware.co.uk/2005/2009/01/08/functional-testing-in-grails-just-got-a-bit-sexier/ but it didn’t work out for me.
    But the method expained by you really works

    Thanks Chandan

Leave a Reply