SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Passing parameters from a function back to test

    Hello,

    I am new to QTP and trying to figure something out. I have a test which calls a public function called MainGate

    code: Call MainGate(DataTable_Inmate,KeyWord,Surname,Forename ,Sex,DoB)

    I have opened a datatable connection and am passing the related variables to the function for input, which is fine.

    I now want to collect information from the function and reuse it in my test but I have no idea how to do that.

    I have the following in my function:
    Committal_Surname=OracleFormWindow("View and Create New Order").OracleTextField("Surname").GetROProperty(" value")

    Though if I try to use Commitall_Surname in my test it won't work because I haven't passed it back from my function.

    What would be the best way of doing this?

    Thanks,

    Paul

  2. #2
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,555
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters from a function back to test

    If you are just looking to pass back one value, use the built in function return. From a purist perspective if you are not returning a value you should be using a Sub rather than a Function anyway.

    Function abba
    abba = 1 'Set function name to a value and that is what it will return
    End Function

    a = abba

    a will equal 1.

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters from a function back to test

    Sorry, slightly confused. From my test I am calling a function called MainGate. There are 6 variables that are being sent to my function so that it can run through my datatable. So I pass them through using

    <font color="red">

    Call MainGate(DataTable_Customers,Keyword,Surname,Foren ame,Sex,DoB)

    </font>

    This is the basic code of my MainGate function:


    <font color="green">
    Public Function MainGate(DataTable_Customers,Keyword,Surname,Foren ame,Sex,DoB)
    'Paramaeters passed from Add_customers test


    Dim New_Surname

    OracleFormWindow("Order").SelectMenu "Movements-&gt;External-&gt;Orders "

    ' ADD NEW CUSTOMER INFORMATION

    OracleFormWindow("New Customer").OracleTextField("Surname").SetFocus
    JavaWindow("New Customer orders").JavaButton("01 Add record").Click

    If OracleFormWindow("New Customer").OracleTextField("Surname").GetROPropert y("value")= "" THEN

    OracleFormWindow("New Customer").OracleTextField("Surname").Enter Surname
    <font color="red">
    New_Surname=OracleFormWindow("New Customer").OracleTextField("Surname").GetROPropert y("value")

    </font>


    OracleFormWindow("New Customer").OracleTextField("Forename(s)").Enter Forename
    Customer_Forename=OracleFormWindow("New Customer").OracleTextField("Forename(s)").GetROPro perty("value")

    OracleFormWindow("New Customer").OracleList("Sex").Select "Male"
    OracleFormWindow("New Customer").OracleTextField("DoB").Enter DoB

    Customer_DoB=OracleFormWindow("New Customer").OracleTextField("DoB").GetROProperty("v alue")

    JavaWindow("New Customer Orders").JavaButton("01 Save").Click
    End If

    End If

    'Export the Data table which now has Yes beside the used record.
    datatable.value("KeyWord", dtLocalDataSheet) = "Yes"
    DataTable.Export(DataTable_Customers)



    End If
    OracleFormWindow("New Customer Orders ").CloseWindow
    End Function

    </font>

    What I don't know is how I pass New_Surname back to the Add_Customer test that called this function in the first place?

    Thanks

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    Bengaluru
    Posts
    494
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters from a function back to test

    'Calling your function in Test
    <font class="small">Code:</font><hr /><pre>
    strName = MainGate(DataTable_Customers,Keyword,Surname,Foren ame,Sex,DoB) </pre><hr />

    'Inside function
    <font class="small">Code:</font><hr /><pre>
    Public Function MainGate(DataTable_Customers,Keyword,Surname,Foren ame,Sex,DoB)

    'statements

    'Return the new Name
    MainGate = New_Surname

    End Function</pre><hr />
    Suraj

  5. #5
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,555
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Passing parameters from a function back to test


 

 

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 10:38 AM.

Copyright BetaSoft Inc.