Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6228327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:22:10+00:00 2026-05-24T09:22:10+00:00

We are trying to build a jmeter testcase which does the following: login to

  • 0

We are trying to build a jmeter testcase which does the following:

  • login to a system
  • obtain some information and check whether correct.

Where we are facing issues is because there is a captcha while logging into the system. What we had planned to do was to download the captcha link and display, and wait for user to type in the value. Once done, everything goes as usual.

We couldnt find any plugin that can do the same? Other than writing our own plugin, is there any option here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:22:12+00:00Added an answer on May 24, 2026 at 9:22 am

    I was able to solve it myself. The solution is as follows:

    • Create a JSR223 PostProcessor (using Groovy)
    • more practical CAPTCHA example with JSESSIONID handling and proxy setting
    • using image.flush() to prevent stale CAPTCHA image in dialog box

    JSR223 Parameters for proxy connection setting:

    Parameters: proxy 10.0.0.1 8080
    

    In it, the following code displays the captcha and waits for user input

                    import  java.awt.Image;
                    import  java.awt.Toolkit;
                    import  javax.swing.Icon;
                    import  javax.swing.JOptionPane;
                    
                    import org.apache.jmeter.threads.JMeterContextService;
                    import org.apache.jmeter.threads.JMeterContext;
                    import org.apache.jmeter.protocol.http.control.CookieManager;  
                    import org.apache.jmeter.protocol.http.control.Cookie;
    
                    URL urlTemp ;
                    urlTemp = new URL( "https://your.domainname.com/endpoint/CAPTCHACode"); 
                    HttpURLConnection myGetContent = null;
                    if(args[0]=="proxy" ){
                       Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(args[1], Integer.parseInt(args[2])));
                       myGetContent = (HttpURLConnection) urlTemp.openConnection(proxy);
                    }else{
                           myGetContent = (HttpURLConnection) urlTemp.openConnection();
                    } 
                    // false for http GET
                    myGetContent.setDoOutput(false);
                    myGetContent.connect();
                    int status = myGetContent.getResponseCode();
                    log.info("HTTP Status Code: "+Integer.toString(status));
                    if (status == HttpURLConnection.HTTP_OK) {
                        //We have 2 Set-Cookie headers in response message but 1 Set-Cookie entry in Map
                        String[] parts2;        
                        for (Map.Entry<String, List<String>> entries : myGetContent.getHeaderFields().entrySet()) {
                               if( entries.getKey()  == "Set-Cookie"   ){
                                for (String value : entries.getValue()) {
                                   if ( value.contains("JSESSIONID") == true   ){
                                         String[] parts = value.split(";",2);
                                         log.info("Response header: "+ entries.getKey() + " - " +  parts[0] );
                                         JMeterContext context = JMeterContextService.getContext();
                                         CookieManager manager = context.getCurrentSampler().getCookieManager();
                                         parts2 = parts[0].split("=",2)
                                         Cookie cookie = new Cookie("JSESSIONID",parts2[1],"your.domainname.com","/endpoint",true,0, true, true, 0);
                                         manager.add(cookie);
                                         log.info( cookie.toString() );
                                         log.info("CookieCount "+ manager.getCookieCount().toString() );
                                    }
                                }                                            
                                }
                           }//end of outer for loop
                               if ( parts2.find() == null ) {
                                  throw new Exception("The Response Header not contain Set-Cookie:JSESSIONID=  .");
                              }         
                    }else{
                            throw new Exception("The Http Status Code  was ${status} , not expected 200 OK.");
                    }
                    BufferedInputStream bins = new BufferedInputStream(myGetContent.getInputStream());
                    String destFile = "number.png";
                    File f = new File(destFile);
                    if(f.exists() ) {                         
                        boolean fileDeleted =  f.delete();
                        log.info("delete file ... ");  
                        log.info(String.valueOf(fileDeleted));
                    }
                    FileOutputStream fout =new FileOutputStream(destFile);
                    int m = 0;
                    byte[] bytesIn = new byte[1024];
                    while ((m = bins.read(bytesIn)) != -1) {
                        fout.write(bytesIn, 0, m);
                    }
                    fout.close();
                    bins.close();
                    log.info("File " +destFile +" downloaded successfully");                               
                    Image   image = Toolkit.getDefaultToolkit().getImage(destFile);
                    image.flush(); // release the prior cache of Captcha image
                    Icon icon = new javax.swing.ImageIcon(image);
                    JOptionPane pane = new JOptionPane("Enter Captcha", 0, 0, null);
                    String captcha = pane.showInputDialog(null, "Captcha", "Captcha", 0, icon, null, null);
                    captcha = captcha.trim();
                    captcha = captcha.replaceAll("\r\n", "");
                    log.info(captcha);                 
                    vars.put("captcha", captcha);
                    myGetContent.disconnect();
    

    By vars.put method we can use the captcha variable in any way we want. Thank you everyone who tried to help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am trying to build a point system which checks how much points a user
I am trying to build an NLP system for an assignment, for which I
I'm trying build a method which returns the shortest path from one node to
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I'm trying to build a grammar with the following: NUMERIC: INTEGER | FLOAT |
I am trying build a DataTable one row at a time using the following
Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object
Trying to build a plugin effect that will some what look better than this
Trying to build a micro-CMS (of sorts), which needs to dish out content i.e.
Im trying to build a feeds application in php in which im using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.