SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    how to dereference parms passed to an Action?

    I have spent the better part of a few hours prowling through the QTP online help trying to understand parameter passing to and from an Action.

    These descriptions seem circular and convoluted--which is unlike many other QTP features described in online help.

    I have also searched the forum and have found others who have asked similar questions--but the threads generally peter out without a definative resolution to many of the questions, for example Mary's recent posting:

    http://www.sqaforums.com/showflat.ph...e=0#Post362249

    But I digress...

    Here is my specific question:

    1. In the scenario where ActionA calls ActionB, where ActionB expects input parameters, is the only way to dereference (i.e. get and use) the input parameters in Action B by using the Parameter object?

    2. The following text is extracted from online Help:
    [ QUOTE ]

    The following example runs one iteration of the action, supplies a string value of MyValue for the input parameter, and stores the resulting value of the output parameter in a variable called MyVariable.
    .
    RunAction "Action2", oneIteration, "MyValue", MyVariable


    [/ QUOTE ]

    Unfortunately none of the online help examples show code statements from Action2, as it relates to how Action2 reads the passed input parameter, "MyValue", or how it writes the passed MyVariable var. Would someone please provide an Expert View line of code for each? For instance:
    <font class="small">Code:</font><hr /><pre>
    dim myString
    myString = ??"MyValue"?? 'how do I get the "MyValue" string?
    '
    ??MyVariable??=1234 'can I use the passed var as if it is a global var?
    </pre><hr />
    3. If you use the Action Call Properties dialog to define input and output Parameter Values, is it then possible to read and write these values in the Expert View?

    -Thanks, Terry

  2. #2
    Senior Member
    Join Date
    Mar 2006
    Location
    Bristol, UK
    Posts
    1,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    I'll have a go no. 2 please;

    Within the Action Properties of Action 2, you have to set up the input &amp; output parameters. You would give these names such as "strInput" &amp; "strOutput".

    When you then call Action 2 within Action 1 you set those variables as you have shown;

    e.g. RunAction "Action2", oneIteration, "MyValue", MyVariable.

    The order is all the input variables than all the output variables. If you are in expert view for Action 1, you can right click on the call to Action 2 and can set the variables through a nice GUI, although I use expert view instead.

    Hopefully all this makes sense. If so, then in Action 2;

    myString = Parameter("strInput")

    Parameter("strOutput") = "1234"

    Then within action 1, after you called action 2, MyVariable is equal to "1234".

    With regards to no. 3;

    You can't create or delete parameters in expert view but you can set them.

  3. #3
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    [ QUOTE ]

    snip...

    RunAction "Action2", oneIteration, "MyValue", MyVariable.
    '
    myString = Parameter("strInput")
    '
    Parameter("strOutput") = "1234"


    [/ QUOTE ]

    I don't understand either of these suggestions, as the related the the example's syntax. I must have some type of mental block on this...

    Lets start with the input parameter. The value I anticipate will be placed in myString is the string literal, "MyValue". So are you saying to get that string I would really use Parameter("strInput")? Is the string, "strInput" some type of hardwired dereference value? And if so, how do I then dereference more than one input value?

    Essentially I have the same question about your suggested Parameter("strOutput") syntax. But in this case are you saying the precise syntax, referring to the example, would be Parameter("MyVariable")=1234.

    -Terry

  4. #4
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    After much trial and error experimentation, and many trips to and from the online documentation, I have finally figured out how this non-vbScript, non-function call/return, implementation supports declaring and then "passing" input and output values to/from an Action.

    There must be SOME story behind why it is done this way, but with all proprietary tools "it works this way because that's the way it is"!

    So, no one needs to reply back to this thread with anymore input or suggestions.

    Later, when time permits I will post some code and comments which will hopefully clarify this lame I/O mechanism to others new to QTP.

    -Later, Terry

  5. #5
    Senior Member
    Join Date
    Mar 2006
    Location
    Bristol, UK
    Posts
    1,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    "strInput" &amp; "strOutput" are just names I used in my example.

    I haven't got QTP in front of me at the moment but from memory, have Action 2 open in expert view. View the Action Properties (try right click). There should be a tab called input parameters and a tab called output parameters. Clicking on these allow you to create the parameters with any names you want.

    When you call Action2 from Action1, the values for the input parameters should be detailed first in the order they were created, then the variables for the output parameters.

    Within Action 2, you reference these values with Parameter("x") where x is the name you assigned previously.

    I must apologise for my attempts to explain this!

  6. #6
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    NP Robbie. I just now figured out that:

    a. You HAVE to use the Step-&gt;Action Properties dialog's Parameter tab to declare the input and output parm names used internal to the Action; AND

    b. You have to ORDER the passed parms in the RunAction invocation to match the parms expected by the called Action's Parameter tab declarations.

    In particular the fact that I HAVE to use a GUI dialog to declare the Action's I/O parms really irks me--this was just so non-intuitive to me. But just as distasteful, I also don't want to use global objects or variables to communicate between Actions. Crappy alternatives all.

    -Terry

  7. #7
    Member
    Join Date
    Jan 2007
    Posts
    74
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    I am glad I put most of my code in .vbs files, I was having the same "mental block" as Terry on the matter. It was a bit confusing to me as well.

    This issue along with several others is what pushed me towards keeping as much of my code as possible outside the QTP actions and in function libraries. This has allowed me to pass parameters around the normal way.

  8. #8
    Senior Member
    Join Date
    May 2004
    Location
    Lakeland, FL
    Posts
    299
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    why bother? I experimented with them a while ago and ran into similar issues (declaring through gui is rather annoying).. biggest problem I had with it was not being able to pass objects (at least in 8.2 anyway). Environment variables are just easier to work with in my mind and support objects.
    JFry

  9. #9
    Senior Member
    Join Date
    Mar 2006
    Location
    Bristol, UK
    Posts
    1,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    I've always used action parameters, mainly because that's how I learnt from the tutorial and my framework has continued to evolve from this.

    One thing that has just sprung to mind is that using action parameters does have a great advantage over other techniques. This is that I can call the re-useable action without having have any knowledge of its inner workings.

    e.g

    For an action called "Log in" with two action parameters called username &amp; password, I could code it as follows;

    RunAction "Log in", oneIteration, "tester", "password1"

    Where as if I referenced environmental variables or a global dictionary, before I called the action I would need to look at the code of that called action to find out what the name of the variables were, then code it as follows;

    Environment("username") = "tester"
    Environment("password") = "password1"
    RunAction "Log in", oneIteration

    Using action parameters allow less experienced people to create their own scripts using your re-useable actions. Obviously, the GUI would make this even more easier.

  10. #10
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to dereference parms passed to an Action?

    Jeremy,

    I just experimented with objects trying to pass them in or out. As you state (I am currently using 8.2) you can't. If only I could pass an object in, this would be tolerable.

    So you went the route of communicating through global variables (env vars or lib globals, all the same to me). What do you do, reserve a global obj per Action, then init that global obj prior to calling the Action? You have to ensure the caller and the called use the same "well known" global name. This sounds very messy and error prone if you have lots of shared Actions.

    Any comments will be appreciated.

    -Thanks, Terry

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 08:20 AM.

Copyright BetaSoft Inc.