SPONSORS:






User Tag List

Results 1 to 9 of 9
  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    161
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to get the return value of a function ?

    User Sushobhan Das (das_sushobhan@yahoo.com.nospam) posted:

    Hi,

    My problem is ...

    What SilkTest returns if a function is execcuted properly & how to get this
    value ?

    To make the point clear, Let me explain the problem. I have the following
    lines of code.

    Browser.Invoke() ( Line No. 1 )
    if ( Line No. 1 is executed properly ...)
    Print ("Success")
    else
    Print ("Fail")

    I want to know what should I put inside the If clause so that I can check
    whether the "Browser.Invoke()" is executed properly or not.


    Thanks in advance,
    Sushobhan

    __________________________________________________

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Location
    Hartford, CT, USA
    Posts
    163
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    User Jaimini Bhatt (jaiminita@yahoo.com.nospam) posted:

    It probably returns a boolean value depending upon execution of a value. I would try it like this:

    boolean bStatus = Browser.Invoke()
    if bStatus
    ....PerformSomeThing
    if !(bStatus)
    ...DoSomeThingElse

    ----- Original Message -----
    From: Sushobhan Das
    To: silktest@yahoogroups.com
    Sent: Sunday, November 11, 2001 11:21 PM
    Subject: [silktest] How to get the return value of a function ?


    Hi,

    My problem is ...

    What SilkTest returns if a function is execcuted properly & how to get this
    value ?

    To make the point clear, Let me explain the problem. I have the following
    lines of code.

    Browser.Invoke() ( Line No. 1 )
    if ( Line No. 1 is executed properly ...)
    Print ("Success")
    else
    Print ("Fail")

    I want to know what should I put inside the If clause so that I can check
    whether the "Browser.Invoke()" is executed properly or not.


    Thanks in advance,
    Sushobhan

    __________________________________________________
    Jaimini Bhatt

  3. #3
    Member
    Join Date
    Oct 2001
    Posts
    93
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    Sushobhan,

    In the main, what Jaimini says is correct, however, in the case of your problem the Invoke method does not return any value. Because of this you will need to use another method to check that window exists. Try:

    Browser.Invoke() ( Line No. 1 )
    if Browser.Exists ()
    Print ("Success")
    else
    Print ("Fail")

    When yo come across situations like this, always check in the Library Browser and/or help to find out what the return type of the method you want to use is. If none is given, it means the method does not return a value so you need to look for another method that does what you want to do.

    Regards,

    Paul

    ------------------
    Paul Tucker
    Merit AT
    www.merit-at.com

  4. #4
    Junior Member
    Join Date
    Sep 2001
    Location
    WestBorough
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    User Srinivas Yeruva (srinireddys@yahoo.com.nospam) posted:

    Hi Das,

    You can check like this
    Browser.Invoke()
    if (Browser.Exists(15))
    Print("Success")
    else
    LogError("Failed")

    But the first line Browser.Invoke() is a Function.If
    you need to verify this function you need to add some
    more code in your Invoke function itself to check
    whether somewhere it is going wrong.
    Generall Invoke() function basically looks for
    sCmdline statement i.e path where your application is
    installed and if the path gets changed it returns with
    an error 'Path not found' some thing like that.

    Good luck!

    Srini

    --- Sushobhan Das <das_sushobhan@yahoo.com> wrote:


    __________________________________________________

  5. #5
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by ptucker:
    in the case of your problem the Invoke method does not return any value. Because of this you will need to use another method to check that window exists.
    <HR></BLOCKQUOTE>

    I believe the invoke method will raise an error if the window to be invoked does not exist after the call to invoke. So you could probably just use a do except instead of the if else you originally detailed.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>
    Browser.Invoke() ( Line No. 1 )
    if ( Line No. 1 is executed properly ...)
    Print ("Success")
    else
    Print ("Fail")
    <HR></BLOCKQUOTE>

    try

    do
    Browser.Invoke()
    Print("Success") //won't get here if it fails
    except
    LogError ("Fail")


    or if you want to return a value

    do
    Browser.Invoke()
    return TRUE
    except
    return FALSE


    ------------------


    [This message has been edited by BrianCarroll (edited 11-12-2001).]

  6. #6
    Member
    Join Date
    Oct 2001
    Posts
    93
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    Srinis,

    What you say is correct (almost!). Invoke is a method (it applies to a particular window or type of window). As the Browser declaration is an instance of the MainWin class, you need to create a new MainWin class derived from MainWin and override the Invoke method. This can be done as below

    winclass MainWin : MainWin
    //Override the default invoke method
    Invoke ()

    //call the original invoke method
    derived::Invoke ()

    //Check if the window exists
    if this.Exists ()
    print ("Success")
    else
    print ("Fail")

    SilkTest,

    If you do not need to do this too often I would stick with using Exists as it is simpler. If you just want to check the Browser is running before a test starts, I would just leave it and let the recovery system deal with it for you. If you run tests from DefaultBaseState, it should start the Browser itself. If the browser does not start, SilkTest will let you know pretty quickly.

    Cheers,

    Paul


    ------------------
    Paul Tucker
    Merit AT
    www.merit-at.com

  7. #7
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    you do not need to override the MainWin class to define your own invoke method. you only need to override invoke in the specific mainwin declaration of interest.

    ------------------

  8. #8
    Member
    Join Date
    Oct 2001
    Posts
    93
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    Brian,

    This is true in most cases where you are creating the window declarations yourself. However, Browser is predefined in the default include files that ship with Silk, so in order to change just the declaration for Browser you need to edit these files. In my experience this is risky as the changes are invariably forgotten about and when Silk is upgraded the changes are overwritten, the test stop working and everyone gets very confused as to why.

    In the main though (Browser aside), as you say, I would just change the method in the object declaration so that my change only applies to that window.

    Paul

    ------------------
    Paul Tucker
    Merit AT
    www.merit-at.com

  9. #9
    Member
    Join Date
    Oct 2001
    Posts
    93
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to get the return value of a function ?

    Brian,

    This is true in most cases where you are creating the window declarations yourself. However, Browser is predefined in the default include files that ship with Silk, so in order to change just the declaration for Browser you need to edit these files. In my experience this is risky as the changes are invariably forgotten about and when Silk is upgraded the changes are overwritten, the test stop working and everyone gets very confused as to why.

    In the main though (Browser aside), as you say, I would just change the method in the object declaration so that my change only applies to that window.

    Paul

    ------------------
    Paul Tucker
    Merit AT
    www.merit-at.com

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin 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 04:11 PM.

Copyright BetaSoft Inc.