Reputation: 262
Request in JSR223 Sampler works correctly, but here are Sampler result and Response data with 0 and empty values:
Metrics in Sample result in red rectangle are equal to 0. No response data (both headers and body) are available to see.
Is it possible to get somehow real numbers instead of 0 0 0 0 0 0 for metrics in Sampler result tab and to have visible response in Response data tab?
Upvotes: 2
Views: 1125
Reputation: 34516
As per reference documentation, you can call those methods:
SampleResult.connectEnd();
SampleResult.latencyEnd();
SampleResult.sampleEnd();
SampleResult.setResponseData(driver.getPageSource(), "UTF-8");
You can use SampleResult javadocs to see all method or subclasses or custom class of yours.
Note SampleResult is a variable name that JMeter binds into element, not the class, so:
Edit (after you added your JSR223 Sampler code):
To fill latency and connect time, use:
As you can get values from Webdriver#executeScript() using such code that exploits Timing API:
long pageLoadTime= (Long)js1.executeScript("return (window.performance.timing.loadEventEnd-window.performance.timing.responseStart)");
long latency= (Long)js1.executeScript("return (window.performance.timing.responseStart-window.performance.timing.navigationStart)");
long endtoEndRespTime= (Long)js1.executeScript("return (window.performance.timing.loadEventEnd-window.performance.timing.navigationStart)");
long connectTime= (Long)js1.executeScript("return (window.performance.timing.connectEnd -window.performance.timing.connectStart)");
Upvotes: 3
Reputation: 168002
Connect time and latency - you need to get it from the Navigation Timing API using WebDriver.executeScript() function, once done you can use SampleResult.setConnectTime()
and SampleResult.setLatency()
Response can be obtained using WebDriver.getPageSource() function so you should be able to do something like:
SampleResult.setResponseData(driver.getPageSource())
SampleResult.setBytes(driver.getPageSource().length())
Remove import of org.apache.jmeter.samplers.SampleResult
as it comes as a pre-defined shortcut
Upvotes: 1