Forum Discussion

punekar's avatar
punekar
Occasional Contributor
12 years ago

String operations on a parameter value as input to another parameter

I have parameter A which is populated by extracting data from a previous Response.



I now want to create parameter B which will contain a substring of parameter A and use this in next Request.



Is this possible and how do we do this?

3 Replies

  • punekar's avatar
    punekar
    Occasional Contributor
    Additionally, is it possible to output the values of captured variables into a text file?



    How does one do that?
  • AlexeyKryuchkov's avatar
    AlexeyKryuchkov
    SmartBear Alumni (Retired)
    Hi Suresh,



    I have parameter A which is populated by extracting data from a previous Response.



    I now want to create parameter B which will contain a substring of parameter A and use this in next Request.



    Is this possible and how do we do this?


    I'd accomplish this by defining another data selector. For example, if I need to extract the first two characters from the value of the __VIEWSTATE parameter, I will use the following regular expression and mask:

    \sname\s*?\=\s*?"__VIEWSTATE"[^^]*?\svalue\s*?\=\s*?"((.{2}).*?)"[^^]*?>



    $2


    Actually, this is a slight modification of the regular expression that is used to extract the whole value of the __VIEWSTATE parameter. Here's the original expression and mask:

    \sname\s*?\=\s*?"__VIEWSTATE"[^^]*?\svalue\s*?\=\s*?"(.*?)"[^^]*?>



    $1




    Additionally, is it possible to output the values of captured variables into a text file?



    How does one do that?


    Currently, there's no way to do this. If you share a use case, we could consider this as an improvement idea.
  • punekar's avatar
    punekar
    Occasional Contributor


    Mike - 



    Thanks for your response. Consider this:



    * I invoke a search on a parameter, say File ID.



    * Depending on the amount of data in the system I bring back a different number of records, and these are paginated 25 items to a page.



    * Since I have 300 vusers in a test, I want each of these to select a different item, on a different page. They then send a subsequent request to open that item.



    Based on what you're saying, and what I've already done in LoadComplete, I can search on File ID and get the number of results into a variable without issues. This is our "range".



    However, how do I get individual vusers to select different items in that range? If there are not enough items, I want only the first few vusers to go ahead with selection, and the others to move on to the next task in the script.



    Of course, this is not the simple matter of taking a substring from the original Regexp. You will need to do something like converting that range into a number, which is the upper limit for another parameter.





    *** Problem #2 ***



    When I'm running multiple vusers in a scenario, which open a particular item from a search, the web application opens a connection over CA Cohesion to a mainframe-based GL (General Ledger application) and queries it about the status of that particular item. The string returned as a "description" can be different for each one, and some of these, as we are discovering are error messages as well. These errors only occur during a performance/load test with multiple connections. I've been asked to document such failures, so the development/infrastructure team can look at specifics.



    Previously I was using LoadRunner for my tests, so it was a simple matter to send something to the output. If nothing else, I would do File I/O in the VUser script and spit it out into a file on disk.



    Kindly explain how I can achieve this in LoadComplete.