Jmeter - convert a string to base64












0














I've just started out trying to write some tests in jmeter. It's the first time I've used it in earnest, and I'm struggling a bit with it.



I am running a test that searches for data on a website.



The returned data is in the format baseURL/customerID=



Now, the customer number depends on the customer being searched for and it is in base64.



I'm struggling to see how I can get the url updated.



I can see in the request that the field is parameter, and I know what the value is, as I have it stored in a csv file as CustomerID.



How can I convert that csv data to the url parameter?



I'm trying to use beanshell at the moment with this:



import org.apache.commons.codec.binary.Base64;

String customerID = vars.get("customerID");
String customerStringEncoded = Bas64Encoder.encode(customerID);
vars.put("customerStringEncoded",customerStringEncoded);


But it seems that it can't locate customerID.



I am supplying it wiht ${CustomerID} in the preprossor menu option, but I don't know what is wrong.



the error is "Typed variable declaration : Attempt to resolve method: encode() on undefined variable or class name: Bas64Encoder
"



Any tips?



Thanks



tgb










share|improve this question



























    0














    I've just started out trying to write some tests in jmeter. It's the first time I've used it in earnest, and I'm struggling a bit with it.



    I am running a test that searches for data on a website.



    The returned data is in the format baseURL/customerID=



    Now, the customer number depends on the customer being searched for and it is in base64.



    I'm struggling to see how I can get the url updated.



    I can see in the request that the field is parameter, and I know what the value is, as I have it stored in a csv file as CustomerID.



    How can I convert that csv data to the url parameter?



    I'm trying to use beanshell at the moment with this:



    import org.apache.commons.codec.binary.Base64;

    String customerID = vars.get("customerID");
    String customerStringEncoded = Bas64Encoder.encode(customerID);
    vars.put("customerStringEncoded",customerStringEncoded);


    But it seems that it can't locate customerID.



    I am supplying it wiht ${CustomerID} in the preprossor menu option, but I don't know what is wrong.



    the error is "Typed variable declaration : Attempt to resolve method: encode() on undefined variable or class name: Bas64Encoder
    "



    Any tips?



    Thanks



    tgb










    share|improve this question

























      0












      0








      0







      I've just started out trying to write some tests in jmeter. It's the first time I've used it in earnest, and I'm struggling a bit with it.



      I am running a test that searches for data on a website.



      The returned data is in the format baseURL/customerID=



      Now, the customer number depends on the customer being searched for and it is in base64.



      I'm struggling to see how I can get the url updated.



      I can see in the request that the field is parameter, and I know what the value is, as I have it stored in a csv file as CustomerID.



      How can I convert that csv data to the url parameter?



      I'm trying to use beanshell at the moment with this:



      import org.apache.commons.codec.binary.Base64;

      String customerID = vars.get("customerID");
      String customerStringEncoded = Bas64Encoder.encode(customerID);
      vars.put("customerStringEncoded",customerStringEncoded);


      But it seems that it can't locate customerID.



      I am supplying it wiht ${CustomerID} in the preprossor menu option, but I don't know what is wrong.



      the error is "Typed variable declaration : Attempt to resolve method: encode() on undefined variable or class name: Bas64Encoder
      "



      Any tips?



      Thanks



      tgb










      share|improve this question













      I've just started out trying to write some tests in jmeter. It's the first time I've used it in earnest, and I'm struggling a bit with it.



      I am running a test that searches for data on a website.



      The returned data is in the format baseURL/customerID=



      Now, the customer number depends on the customer being searched for and it is in base64.



      I'm struggling to see how I can get the url updated.



      I can see in the request that the field is parameter, and I know what the value is, as I have it stored in a csv file as CustomerID.



      How can I convert that csv data to the url parameter?



      I'm trying to use beanshell at the moment with this:



      import org.apache.commons.codec.binary.Base64;

      String customerID = vars.get("customerID");
      String customerStringEncoded = Bas64Encoder.encode(customerID);
      vars.put("customerStringEncoded",customerStringEncoded);


      But it seems that it can't locate customerID.



      I am supplying it wiht ${CustomerID} in the preprossor menu option, but I don't know what is wrong.



      the error is "Typed variable declaration : Attempt to resolve method: encode() on undefined variable or class name: Bas64Encoder
      "



      Any tips?



      Thanks



      tgb







      jmeter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 20:37









      thegoatboythegoatboy

      11




      11
























          1 Answer
          1






          active

          oldest

          votes


















          0














          If the data is being stored in csv, you can use the "CSV Data Set config" to read the CSV File. CSVhttp://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config






          share|improve this answer





















          • Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
            – thegoatboy
            Nov 20 '18 at 6:13












          • This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
            – thegoatboy
            Nov 20 '18 at 6:23












          • I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
            – thegoatboy
            Nov 20 '18 at 11:00










          • You can use Integer.parseInt(vars.get("")) to convert into an integer
            – Usr_Dev
            Nov 21 '18 at 21:26











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382274%2fjmeter-convert-a-string-to-base64%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If the data is being stored in csv, you can use the "CSV Data Set config" to read the CSV File. CSVhttp://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config






          share|improve this answer





















          • Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
            – thegoatboy
            Nov 20 '18 at 6:13












          • This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
            – thegoatboy
            Nov 20 '18 at 6:23












          • I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
            – thegoatboy
            Nov 20 '18 at 11:00










          • You can use Integer.parseInt(vars.get("")) to convert into an integer
            – Usr_Dev
            Nov 21 '18 at 21:26
















          0














          If the data is being stored in csv, you can use the "CSV Data Set config" to read the CSV File. CSVhttp://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config






          share|improve this answer





















          • Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
            – thegoatboy
            Nov 20 '18 at 6:13












          • This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
            – thegoatboy
            Nov 20 '18 at 6:23












          • I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
            – thegoatboy
            Nov 20 '18 at 11:00










          • You can use Integer.parseInt(vars.get("")) to convert into an integer
            – Usr_Dev
            Nov 21 '18 at 21:26














          0












          0








          0






          If the data is being stored in csv, you can use the "CSV Data Set config" to read the CSV File. CSVhttp://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config






          share|improve this answer












          If the data is being stored in csv, you can use the "CSV Data Set config" to read the CSV File. CSVhttp://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 0:23









          Usr_DevUsr_Dev

          2718




          2718












          • Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
            – thegoatboy
            Nov 20 '18 at 6:13












          • This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
            – thegoatboy
            Nov 20 '18 at 6:23












          • I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
            – thegoatboy
            Nov 20 '18 at 11:00










          • You can use Integer.parseInt(vars.get("")) to convert into an integer
            – Usr_Dev
            Nov 21 '18 at 21:26


















          • Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
            – thegoatboy
            Nov 20 '18 at 6:13












          • This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
            – thegoatboy
            Nov 20 '18 at 6:23












          • I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
            – thegoatboy
            Nov 20 '18 at 11:00










          • You can use Integer.parseInt(vars.get("")) to convert into an integer
            – Usr_Dev
            Nov 21 '18 at 21:26
















          Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
          – thegoatboy
          Nov 20 '18 at 6:13






          Hi there. Thanks for responding. I am reading my data from the CSV data set config. Within that file I also have names and other search criteria. The data in the csv file is stored in a text format, but I want to convert it to base64 for the URL. I could do this in the file beforehand, but it would mean changing that data every time I update that file. I want change the format in jmeter. I think I'm close with this piece of code: vars.put("CustomerID", new String(Base64.EncodeBase64($CustomerID}))); but I'm having trouble converting it back into a variable to use
          – thegoatboy
          Nov 20 '18 at 6:13














          This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
          – thegoatboy
          Nov 20 '18 at 6:23






          This is the current error I am encountering:Encountered "( "CustomerID" , new String ( Base64 . EncodeBase64 ( $CustomerID }"
          – thegoatboy
          Nov 20 '18 at 6:23














          I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
          – thegoatboy
          Nov 20 '18 at 11:00




          I seem to be getting closer. I'm currently trying this int num = vars.get(${CustomerID}); However, it seems that you can't use vars.get with an int. Anyone know how to convert it?
          – thegoatboy
          Nov 20 '18 at 11:00












          You can use Integer.parseInt(vars.get("")) to convert into an integer
          – Usr_Dev
          Nov 21 '18 at 21:26




          You can use Integer.parseInt(vars.get("")) to convert into an integer
          – Usr_Dev
          Nov 21 '18 at 21:26


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382274%2fjmeter-convert-a-string-to-base64%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]