Script Runner

User rating:
3.3 (12 ratings)

The content on this page is related to a deprecated version of LoadUI, which has been superseded by LoadUI NG Pro in the Ready! API platform. Click here to learn more.


0.1. Description

This Runner Component runs a Groovy script and output the result of the script. When running a distributed test, the script content is automatically distributed to all assigned Agents.
- Parameters in the trigger message are made available to the script, unless configured not to.
- If the result of the script is a Map, then each entry will be set in the output message. Otherwise, the result will be in the Result column.

0.2. Example scripts

0.3. FTP

The example script below downloads a file from an FTP server and outputs the size and hash of the downloaded file.

// ftp.groovy
@Grab(group='commons-net', module='commons-net', version='2.0')
new FTPClient().with {
   login("anonymous", "anonymous")
   fileType = FTPClient.BINARY_FILE_TYPE
   inFile = new File("c:/temp/install.exe")
   inFile.withOutputStream { ostream -> retrieveFile "install.exe", ostream }

return [ "size":inFile.length(), "hash":Integer.toHexString( inFile.hashCode() ) ]


The following example script sends a HTTP POST request:

@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.1.1')

import org.apache.http.client.methods.HttpPost
import org.apache.http.message.BasicNameValuePair
import org.apache.http.impl.client.DefaultHttpClient
import org.apache.http.client.entity.UrlEncodedFormEntity 
import org.apache.http.protocol.HTTP

post = new HttpPost("")
parameters = new ArrayList() 
parameters.add(new BasicNameValuePair("p", "loadui")) 
sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8)
client = new DefaultHttpClient()   
response = client.execute(post)

return ["responseBody":response.entity.content.text]

0.5. Geb (WebDriver)

@Grab(group='org.codehaus.geb', module='geb-core', version='latest.release')
@Grab(group='org.seleniumhq.selenium', module='selenium-htmlunit-driver', version='latest.release')

import geb.Browser {
  go ""