I'm using a JMeter (2.13 r1665067) to test a site with Google Kaptcha on log in and registration until they can be disabled in a test environment. I've recorded a session and set up a Save Responses to a file sampler to extract the kaptcha image. I then have a Beanshell sampler display it so I can enter the code as needed (thanks to this post).
The problem I'm running into now is the first image retrieved from the server is displayed repeatedly. I've tried setting any objects created in the Beanshell to null post-use, and checking the "Reset bsh.Interpreter before each call".
I was able to get around to issue by using the $__(Random) function to append a unique id to each image when created in the Save Responses to a file sampler, but results in a lot of files being created. I can verify the saved image file is changing on the filesystem. I can also restart JMeter, or clear the file from the filesystem for it to appear properly, but only the first time. Adding a timestamp via the Save Responses to a file sampler isn't unique enough, but creates additional files anyway.
I'd like to find out why JMeter seems to be caching the images and if there's a way to have a single file written and read each time, avoiding the slew of them I'd get by appending a unique ID. I imagine it has to do with my config.
Beanshell sampler code:
filenameOrURL = new URL("file://${FILE2}");
image = Toolkit.getDefaultToolkit().getImage(filenameOrURL);
icon = new javax.swing.ImageIcon(image);
pane = new JOptionPane("Enter Captcha", 0, 0, null);
String captcha = (String)pane.showInputDialog(null, "Captcha", "Captcha", 0, icon, null,null);
filenameOrURL = image = pane = icon = null;
log.info(captcha);
vars.putObject("captcha",captcha);
Save Responses to a file sampler parameters:
Filename prefix: /response/response_
Variable name: FILE
Thread Group:
I'd post an image if my reputation preceded me. :blush:
Recording Controller
login.html (GET)
Save Responses to a file
BeanShell Sampler
login.html (POST)
logout.html (GET)