我需要加载动态资产(图像)的偏见,因为只有一个带有变量传递的采样器。我不能在这里使用并行控制器,也不知道在并行采样器中加载的确切资产数量。
正如您在一个类似的问题之一中所建议的那样,我使用过该方法(添加pre sampler)下面的脚本并尝试执行它,它能够选择值,但子元素始终只有一个(未发生并行请求)但是,我看到URL通过的主要请求已通过了多个通过。
使用的前处理器脚本:
String var2 = vars.get("tokens");
String var3 = vars.get("Token");
vars.put("var3", "https://stagingassets.ovid.com"+"/"+var2+"/t/width-150-png?"+var3);
urlsList = vars.get("var3").tokenize(",")
for (int i = 0; i < urlsList.size(); i++) {
def row = new org.apache.jmeter.testelement.property.CollectionProperty()
row.addItem(urlsList[i])
sampler.data.addItem(row)
log.info("ROWS ${row}")
}
变量来自CSV,其中使用灵活的文件编写器将值保存到每个循环中的文件中。
请建议,我的要求是执行图像在浏览器中发生的情况。
[Jmeter脚本图像] [1]
I have a requirement to load the dynamic assets(Images) parallelly which got extracted from the for each loop as there is only one sampler with variable passed. I cant use the parallel controller here, also I don't know the exact number of assets loaded to pass in parallel sampler.
As suggested by you in one of similar issues I have used that approach(add pre sampler) below script and try to execute it in, It is able to pick the values but the child element is always only one(Parallel requests are not happening) however I see the URL's passed main request has multiple passed.
Pre-Processor script used:
String var2 = vars.get("tokens");
String var3 = vars.get("Token");
vars.put("var3", "https://stagingassets.ovid.com"+"/"+var2+"/t/width-150-png?"+var3);
urlsList = vars.get("var3").tokenize(",")
for (int i = 0; i < urlsList.size(); i++) {
def row = new org.apache.jmeter.testelement.property.CollectionProperty()
row.addItem(urlsList[i])
sampler.data.addItem(row)
log.info("ROWS ${row}")
}
variables are coming from CSV where values are saved into a file from each loop using a Flexible File Writer.
please suggest , My requirement is to execute the images parallelly as it happens in the browser.
[JMeter script image][1]
发布评论
评论(1)
使用并行采样器,可以通过< 一个 href="https://jmeter.apache.org/usermanual/component_reference.html#JSR223_PreProcessor" rel="nofollow noreferrer">JSR223 PreProcessor using the following code snippet:
If you want to mimic browser-like behaviour you需要将平行采样器放在 loop Controller 并将LOOPS数设置为您的URLS/6/6/6/6/6
Use Parallel Sampler, the URLs can be added dynamically via JSR223 PreProcessor using the following code snippet:
If you want to mimic browser-like behaviour you need to put the Parallel Sampler under the Loop Controller and set the number of loops to the number of your URLs / 6