How do I override the response content in a JMeter WebDriver sampler test? When I run the following code, the response that is shown in the response tab of the WebDriver Sampler is the full content of the webpage rather than what I expected to see, a string value of "a message" . Any idea on what I am doing wrong?
var pkg = JavaImporter(org.openqa.selenium)
WDS.sampleResult.sampleStart()
WDS.log.info("Start...")
WDS.browser.get('http://google.com')
WDS.sampleResult.sampleEnd()
java.lang.Thread.sleep( 500 )
WDS.sampleResult.setResponseMessage( "a message" )
WDS.sampleResult.setSuccessful(true)
To reproduce this you need to download the WebDriver plugin pack for JMeter and add a "WebDriver Sampler" step and a "Firefix Driver Config" to your Test plan.
This doesn't work either:
WDS.sampleResult.responseMessage = 'a message'
WDS.sampleResult.successful = true
Nor did this:
WDS.sampleResult.setResponseData("a message", "utf-8")
WDS.sampleResult.setSuccessful(true)
Nor did this:
var message = "Hello World".split('')
WDS.sampleResult.setResponseData( message, 'utf-8' )
WDS.sampleResult.setSuccessful(true)
I am just trying to set a value that I can retrieve in a subsequent test step.
As per code:
ResponseMessage and ResponseData are overwritten by sampler after calling your script code.
So you can't do what you want to.