Forum Discussion

cvalston's avatar
16 years ago

How can I run multiple requests dynamically using the same parameter each time?

Hi there,

I've been looking at the forum entries and I still don't get it.

I have multiple requests in a test case, and I want to dynamically replace the "?" for a node with a value.

For example in the request I have this:

?

which I want to replace with this:

1234 for example.

I've tried this with dynamic properties like so:

${#TestSuite#ConsumerIdProd}

But I have a lot of requests and I want to know how to do this without manually typing in the
dynamic property for each request.

I've seen the property transfer and the groovy examples but they don't seem to answer the
following:

If I have 25 requests that  I want to run one after the other, do I have to create 25 groovy
steps before each request that does the replacement for me or can I just use ONE groovy script
at the beginning of the test case list that would replace the node in all 25 requests?

Also would I need to use xpath on the node here in the request:

1234 in order to replace the "?" with my desired value?

Is it easier to do this with groovy or property transfer?

Can I just create one property transfer step and use it to change the xml request node for each request or do I need one prop transfer step for each request?

Any help would be much appreciated!

thanks,

Carlos
I have to create multiple prop transfer steps
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    I'm not quite sure I understand your problems, but I think you are saying you already have created 25 Test Request steps and you want to insert a property expansion in each one without doing it manually?

    I would probably back up the project xml, open it up in a text editor file and do a search and replace (standard disclaimers apply!)

    Regarding your second issue, if it was the same value you were after in each request, I would do a Property Transfer to a Properties step, then reference that Property in all of the requests.

    Hope this helps.
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi cvalston ,

    It is possible to do using a single groovy script.

    Just follow these steps:

    1 . Put the groovy script  in a single test case Say for Example Name the test case as " Groovy Holder "
    (" Groovy Holder " - This script should update the ser:ConsumerId value based on your test case name) Under this Test Case place your Request too.

    2 . Then you create a another test case name it as "TestCase1" and add one groovy script to this step which should pass the Name of the TestCase to the " Groovy Holder ", Then  " Groovy Holder " will update Value of ser:ConsumerId for TestCase1( In TestCase1 you will have only one step which contains a groovy script )

    So you can create N no of testcases at ease. Now you have only two groovy scripts. The main script is your " Groovy Holder " and another script is in your testcase.

    Note : Use Excel or DataSource to hold ser:ConsumerId for 25 testcases and try to call this sheet in " Groovy Holder" step.

    Hope that answers your question.

    With Regards
    Anand
  • Hi cvalston,
    Have you tried dynamic properties where you can define random numbers?

    customerId = ${=(int)(Math.random()*1000)}