1

I just started my career as a Junior Tester

Step1: Requested XML Data using HTTP Request

    Path: /vitalhub/rest/patientlists
    ResponseData:<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <patientLists lastRefresh="2015-11-16T15:48:21.050-05:00" count="4">
   <patientList modifiable="false" uid="0000000000204016">
    <vhSysSrc>cerner</vhSysSrc>
    <name>Test List</name>
   </patientList>
   <patientList modifiable="false" uid="0000000000204019">
    <vhSysSrc>cerner</vhSysSrc>
    <name>123</name>
   </patientList>
   <patientList modifiable="false" uid="0000000000204021">
    <vhSysSrc>cerner</vhSysSrc>
    <name>Random Patient List</name>
   </patientList>
   <patientList modifiable="false" uid="0000000000204023">
    <vhSysSrc>cerner</vhSysSrc>
    <name>Custom List</name>
   </patientList>
   </patientLists>

Step2: Added a XpathExtractor as

   Reference Name: listName
   Xpath Query:patientLists/patientList/name/text()

Step3: Added debugSampler and these were the results

   JMeterVariables:
   JMeterThread.last_sample_ok=true
   JMeterThread.pack=org.apache.jmeter.threads.SamplePackage@393d25f8
   START.HMS=134134
   START.MS=1447267294003
   START.YMD=20151111
   TESTSTART.MS=1447709583847
   applicationDomain=VitalHubChart
   bulkCiphers=NONE
   deviceId= dev1
   devicePassword=vitalhub123
   key=55fbcb5c-f71a-42ce-995e-72a7c44145b3
   key_1=55fbcb5c-f71a-42ce-995e-72a7c44145b3
   key_matchNr=1
   listName=Test List
   listName_1=Test List
   listName_2=123
   listName_3=Random Patient List
   listName_4=Custom List
   listName_matchNr=4
   password=testcp
   sessionId=f3e8a037-d6e6-4ed4-b5db-993c713417f0
   sessionId_1=f3e8a037-d6e6-4ed4-b5db-993c713417f0
   sessionId_matchNr=1
   user=testcp
   userName=testcp
   userPass= testcp

Step4: Added an other Http Request to get the results by using ListName

  Path: /vitalhub/rest/patientLists/name/${listName_1}

By using Step4 I can just get info of a single list. I have to change it to listName_2..4 to get different list results

How can I automate these requests?

I tried using foreach loop and RegularExpressionExtractor and tried using BeanShellPostProcessor, but was unable to solve it

I would be thankful if anyone can answer my question.

  • I did the same thing but not able to run the ForEachLoop and for extracted list, not able to get output. – Veena MB May 7 at 10:29
3

The easiest way is using ForEach Controller configured as:

  • Input Variable Prefix: listName
  • Output Variable Name: anything meaningful, i.e. currentList
  • Add "_" before number?: checked

    ForEach Controller

This way you will be able to iterate all the listName_X variables:

ForEach Controller in action

See Using Regular Expressions in JMeter guide for another example which extracts all HTML links from web page and hits them all using ForEach Controller.

  • Thank you. I didn't add HTTP Request in ForEach loop. I will try as you explained – chandini Nov 17 '15 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.