Tuesday, 15 September 2015

How to upload files in Scripting Load Runner (Vugen)

How to upload files in Scripting Load Runner(Vugen)

How to upload any local or network files with Load runner scripting:

 There are several options that do the same work:

Running test locally :
Record script where you upload a local file. I suggest placing file in “C:\temp” before recording.
Run the test using same local machines. Test will pass since script and upload file both located in the same machine during recording and test execution.
Keep in mind to replace single backslash with double backslashes in the script. Here is the sample script:
    web_submit_data("AddAttachment.aspx",
     "Action=https://learningshared.com/AddAttachment.aspx",
     "Method=POST",
     "EncType=multipart/form-data",
     "RecContentType=text/html",
     "Snapshot=t7.inf",
     "Mode=HTML",
     ITEMDATA,
         "Name=__VIEWSTATE", "Value={ViewState_Value_1}", ENDITEM,
         "Name=__EVENTVALIDATION", "Value={EVENTVALIDATION_1}", ENDITEM,
         "Name=FileUpload1", "Value=C:\\Temp\\my_uploaded_file.pdf", "File=yes", ENDITEM,
         "Name=Button1", "Value=Upload", ENDITEM,
     LAST);

    Running test with any network load generator:This method is similar to the first method. Therefore, record the script the same way as above.
    Create a network share location with read & write access. Place files those need to be uploaded.
    Replace local file location with network file location. Make sure to replace single backslash with double backslashes in the script. Here is the sample script:
      web_submit_data("AddAttachment.aspx",
       "Action=https://learningshared.com/AddAttachment.aspx",
       "Method=POST",
       "EncType=multipart/form-data",
       "RecContentType=text/html",
       "Snapshot=t7.inf",
       "Mode=HTML",
       ITEMDATA,
           "Name=__VIEWSTATE", "Value={ViewState_Value_1}", ENDITEM,
           "Name=__EVENTVALIDATION", "Value={EVENTVALIDATION_1}", ENDITEM,
           "Name=FileUpload1", "Value=\\\\shared_network_location\\my_uploaded_file.pdf", "File=yes", ENDITEM,
           "Name=Button1", "Value=Upload", ENDITEM,
       LAST);
      
      
       Attach upload file with scripts:
      • This method is similar to the first method. Record the script with a local file.
      • Add all the files (to be uploaded) to scripts by clicking “Add Files to Scripts…” menu from “Files -> Add Files to Scripts…”
      • Now clear file location and just leave the file name. These scripts should run from any load generators in the network or can be run from Performance center ALM too.
      web_submit_data("AddAttachment.aspx",
       "Action=https://learningshared.com/AddAttachment.aspx",
       "Method=POST",
       "EncType=multipart/form-data",
       "RecContentType=text/html",
       "Snapshot=t7.inf",
       "Mode=HTML",
       ITEMDATA,
           "Name=__VIEWSTATE", "Value={ViewState_Value_1}", ENDITEM,
           "Name=__EVENTVALIDATION", "Value={EVENTVALIDATION_1}", ENDITEM,
           "Name=FileUpload1", "Value=my_uploaded_file.pdf", "File=yes", ENDITEM,
           "Name=Button1", "Value=Upload", ENDITEM,
       LAST);
      
      
      LoadRunner Training in Bangalore
      LoadRunner Training in Hyderabad
      LoadRunner Online Training
      LoadRunner Training in BTM
      LoadRunner Training in Marathahalli
      Best LoadRunner Training Institutes in Bangalore 
      Best LoadRunner Training Institutes in India
      Training Institutes in Bangalore
      
      

      6 comments:

      1. Thanks for the Info. Just a question, how do I manage to use the attached upload file in VuGen scripts with the TruClient? Im creating a WebApplication where the user has to click on the webpage and upload a file. Currently if I use a normal Path it works only on localhost (not with the remote LoadGenerators) and by using the attached method you mentioned on your post I haven't been able to make it work. Once again, thanks for your feedback

        ReplyDelete
        Replies
        1. Actually I've found a possible solution. You can use the JS Code TC.scriptDir + "\\MyFile.jpg"

          Delete
        2. Complete Reference On Loadrunner          Contact For Training - +91-8050148265: How To Upload Files In Scripting Load Runner (Vugen) >>>>> Download Now

          >>>>> Download Full

          Complete Reference On Loadrunner          Contact For Training - +91-8050148265: How To Upload Files In Scripting Load Runner (Vugen) >>>>> Download LINK

          >>>>> Download Now

          Complete Reference On Loadrunner          Contact For Training - +91-8050148265: How To Upload Files In Scripting Load Runner (Vugen) >>>>> Download Full

          >>>>> Download LINK I4

          Delete
      2. Thanks for the info. Using Oracle NCA protocol how can we deal with this File Upload function. I have tried to record the file upload with Web+Oracle NCA, but after clicking on Browse button nothing was captured including the File path.Below is the code.
        /* Click Browse */

        nca_set_window("Excel File Upload (ABC_exlflupl)");
        nca_button_press("BL1_PBN_BROWSE_0");
        /* Click on Browse Open */
        /* click on Upload */
        nca_button_press("BL1_PBN_UPLOAD_0");
        Highly appreciate your valuable inputs and solutions.

        Thanks in advance!..:):)

        ReplyDelete

      3. Good Post. You know this article useful for me and everyone I like your blog and good information Thanks for Sharing InformationLoadRunner Training Institute in Delhi

        ReplyDelete
      4. Complete Reference On Loadrunner          Contact For Training - +91-8050148265: How To Upload Files In Scripting Load Runner (Vugen) >>>>> Download Now

        >>>>> Download Full

        Complete Reference On Loadrunner          Contact For Training - +91-8050148265: How To Upload Files In Scripting Load Runner (Vugen) >>>>> Download LINK

        >>>>> Download Now

        Complete Reference On Loadrunner          Contact For Training - +91-8050148265: How To Upload Files In Scripting Load Runner (Vugen) >>>>> Download Full

        >>>>> Download LINK R4

        ReplyDelete