-1

I am studying JMeter and want to make a HTTP GET request to http://google.com using BeanShell Sampler without using HTTP Request Sampler. Is it possible? And if so, how can I do it?

Thanks in advance!

ap6491
  • 805
  • 1
  • 10
  • 26

1 Answers1

1

It is possible however I fail to see why would you need this.

Moreover starting from JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting mainly because Groovy has much better performance comparing to Beanshell, in addition Groovy is more modern language which supports all the latest Java features and provides a lot of enhancements on top of it, see Apache Groovy - Why and How You Should Use It article for more details.

Example code:

import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.util.EntityUtils

HttpClient client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet("http://google.com");
HttpResponse response = client.execute(get);
SampleResult.setResponseData(EntityUtils.toByteArray(response.getEntity()));

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133