How to Access Current Sampler and Regex Variable in JMeter BeanShell Post Proccessor?

23-02-2016

Apache JMeter get current sampler as follows:

String currentURL = ctx.getCurrentSampler().getUrl().getHost();//accessing current URL
name = vars.get("takipKodu");//regex variable named as takipKodu

// Pass true if you want to append to existing file
// If you want to overwrite, then don't pass the second argument
f = new FileOutputStream(currentURL+".txt", true);
p = new PrintStream(f); 
this.interpreter.setOut(p); 
print(name);
f.close();

© 2019 All rights reserved. Codesenior.COM