Results 1 to 8 of 8

Thread: Reusable action

  1. #1

    Reusable action

    I have a reusable action which is called 3 times in my script and my script is iterated for 6 times. The reusable action takes its parameter from its local sheet. The local sheet has 2 rows.

    The reusable action when called for the 1st and 2nd time in the script it should take the 1st row as the parameter and when called for the 3rd time it should take the 2nd row as parameter. This has been set in the action call property of the reusable action.

    However when the script is executed for the 1st iteration it works fine but from the 2nd iteration it fails because reusable action always takes the 2nd row as parameter even thought the action call property setting has been set for that.

    The same script works fine in QTP 8 but fails in QTP9.1. Is there any other additional setting which needs to be done for the script to work fine?

  2. #2
    Advanced Member
    Join Date
    Mar 2007
    Salt Lake City, UT, USA

    Re: Reusable action

    I gave up on letting QTP handle my iterations way back in version 8.0.

    Ever since then, I use the following:
    dtrc = DataTable.GetSheet("xxx").GetRowCount
    For intLoop = 1 to dtrc
    DataTable.GetSheet("xxx").SetCurrentRow intLoop
    (put my main script here)
    Next 'intLoop

    When I call a reusable action, I always run just one iteration and use that same looping code to handle my datatable rows.

    When I call a one-shot reusable action such as yours, where I have multiple data rows but only desire to use one row, I specify the row number as either an action parameter or an environment variable and the reusable action doesn't bother with the rowcount or the For..Next loop. Instead, it just sets the row to be whatever value was passed to it and runs just that one iteration.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  3. #3

    Re: Reusable action

    At end of your action (as last statement in your action) set current row of action sheet to first row.

    DataTable.GetSheet(xxxx).SetCurrentRow 1

    This should solve your problem.

    - VM

  4. #4

    Re: Reusable action

    The solution of adding
    DataTable.GetSheet(xxxx).SetCurrentRow 1
    has not solved my problem

  5. #5

    Re: Reusable action

    this should work

    Anil P

  6. #6

    Re: Reusable action

    Go to New -> Settings -> Run and click on "Run one iteration Only".

    Now run the test.
    Ashish Goel,
    QTP Automation Engineer,

  7. #7

    Re: Reusable action

    So you mean to specify the row number as an action parameter or an environment varaiable. The action parameter or an environment varaiable can be specified only once for the script. So how can i give 2 row numbers as action parameter or an environment.

  8. #8

    Re: Reusable action

    you can set the value of action parmeter or env var during run time. So just assign row number to one of these parameter and use it to set current row within action



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:30 PM.

Copyright BetaSoft Inc.