0

Following are the steps that I need to peform

  1. Make http request call to a sevice which returns a json that has many urls.
  2. Extract all the urls using regular expression extractor
  3. Make http request call to all the exctracted urls asynchronously.

Is there a way we can achieve this? I tried parallel controller but, if I am not wrong, it requires all the request to be mentioned as its child sampler. I don't want to write each and every request manually. Is there a way we can change urls dynamically after running the test plan?

  • You can check BeanShell for doing pre and post processing [specially executing scripts i.e. in you case parsing json etc.] https://dzone.com/articles/beanshell-processor-in-jmeter and https://www.blazemeter.com/blog/how-use-beanshell-jmeters-favorite-built-component – codinnvrends Jun 23 '20 at 08:40
  • A related post is here https://stackoverflow.com/questions/24512365/jmeter-run-a-python-script-before-calling-each-http-request-sampler – codinnvrends Jun 23 '20 at 08:54

1 Answers1

0
  1. It's better to use JSON Extractor if the server returns URLs in JSON format

  2. Once you have the URLs in form of JMeter Variables like:

    url_1=http://example.com
    url_2=http://example.org
    ........
    ........
    url_matchNr=X
    
    • add Parallel Sampler to your Test Plan

    • add JSR223 PreProcessor as a child of the Parallel Sampler

    • Put the following code into "Script" area:

       1.upto(vars.get('url_matchNr') as int, { index ->
           sampler.addURL(vars.get('url_' + index))
       })
      
Dmitri T
  • 159,985
  • 5
  • 83
  • 133