jmeter json path bean post processor -


i have following entries got extracted response using jsonpath extractor

entries = ["e-1553","e-1552","c-1052","e-1551","c-1050",            "e-1550","c-1049","e-1549","c-1051","e-1548",            "c-1048","e-1547","c-1047","e-1546","c-1045",            "e-1545","e-1544","c-1046","e-1543","e-1542",            "c-1026","e-1541","e-1540","e-1539","e-1538",            "c-1025","e-1537","e-1536","c-1024","f-1535",            "f-1534"] 

i want iterate on entries start "e-" e.g. "e-1553,e-1552" etc. in foreach controller , exclude other entries such "c-1052, c-1050" etc.

so can use http://somesite.com/e-1553 etc.

how do that?

given have "entries" variable holds jsonarray can entries start "e-" follows:

  1. add beanshell postprocessor after jsonpath extractor
  2. put following code postprocessor's "script" area:

    jsonarray array = jsonarray.fromobject(vars.get("entries")); int counter = 0; (int i=0;i < array.size();i++) {     string s = array.get(i).tostring();     if (s.startswith("e-"))     {         counter++;         vars.put("entry_" + counter, s);     } } 

it produce variables like:

entry_1=e-1553 entry_10=e-1544 entry_11=e-1543 entry_12=e-1542 entry_13=e-1541 etc. 

then add foreach controller , configure follows:

  • input variable prefix: entry
  • start index loop: 0
  • output variable name: current_entry

then in http request use ${current_entry} in path.

see how use beanshell: jmeter's favorite built-in component guide more information on beanshell scripting in jmeter.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -