Forum Discussion

aksanoop's avatar
aksanoop
Occasional Contributor
12 years ago

Urgent-Not able to test through script runner in LoadUI

Hi Members,

I am working on a very urgent requirement. I want to do Load testing through LoadUI using Script Runner.
For my understanding i am using the below script saved as Test.groovy on my desktop.

******************************************************************************
@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("http://search.yahoo.com/search")

parameters = new ArrayList()
parameters.add(new BasicNameValuePair("p", "loadui"))
sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8)

post.setEntity(sendentity)
client = new DefaultHttpClient()

response = client.execute(post)

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

*************************************************************************
I browsed this script and provided the Fixed Rate Load to the Script Runner. I am catching the output in the Output Table.
When running the all requests are failing. The Output table gives me this error

java.lang.NullPointerException:Cannot set property "binding" on null object

Please help me in rectifying this issue. My work has stuck due to this reason.
Thanks in advance.

With regards,
Anoop.

4 Replies

  • Hi there,

    Could you please try to use httpclient version 4.2.1 at least.
    Grapes (used to Grab this dependency) is having some kind of problem with 4.1.1!
    It worked for me with 4.2.1..... please notice that the latest version of this library in Maven Central is already 4.2.5.

    Unfortunately, LoadUI's ScriptRunner error messages are really unhelpful... please try to run your script with the Groovy Console before trying it in LoadUI so you get a better error message

    By the way, here is a more Groovy version of your script, hope this helps:

    @Grab(group='org.apache.httpcomponents', module='httpclient', version='4.2.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


    def post = new HttpPost("http://search.yahoo.com/search")

    def parameters = [ new BasicNameValuePair("p", "loadui") ]
    def sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8)
    post.entity = sendentity

    def client = new DefaultHttpClient()

    response = client.execute post

    return ["responseBody": response.entity.content.text]
  • aksanoop's avatar
    aksanoop
    Occasional Contributor
    Hi renatoathaydes,

    Thanks for the reply.
    But unfortunately the suggested change has also given the same error.
    I copied the modified code provided by you and got the same error.

    Can you please look into this issue with some more detail to resolve it?
    Is any sytem setting or specific system configuration required?
    Does the script or Load ui need Proxy setttings? If yes, please let me know how to do it.

    Your help will be great.

    Thanks & regards,
    Anoop.
  • aksanoop's avatar
    aksanoop
    Occasional Contributor
    Hi Members,

    Will anybody help me further to solve this issue.
    This is very urgent requirement for me.

    Thanks & regards,
    Anoop.
  • aksanoop's avatar
    aksanoop
    Occasional Contributor
    Hi Members and renatoathaydes

    The issue is resolved now. I just had to modify the httpClient version to 4.1.2. renatoathaydes suggested for version 4.2.1 but that didn't work for me.
    Thanks a lot to renatoathaydes for pointing towards the probable solution. great help indeed.

    Thanks to all members too.

    With regards,
    Anoop.