SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Junior Member
    Join Date
    Apr 2001
    Location
    Scotts Valley, CA
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I execute code when trappped dialog is found?

    My AUT is capable of asynchronous operations, each of which causes a message box to appear some time later reporting success or failure of the operation. I know that I can set up traps for the message box using window.SetTrap method, and that I can specify a button to be pushed, but that's not enough for me, I also want to execute some more automation code at this point based on the success or failure of the operation. Is there a way to do this, or am I really limited to just pushing a button? Since the SetTrap method allows me to specify an exception, could I use a custom exception to execute my additional code? I am very grateful for any ideas you can offer.

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

  2. #2
    Junior Member
    Join Date
    Apr 2001
    Location
    Scotts Valley, CA
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    Can nobody help me with this one? Or is the answer so obvious that I am being scorned by your silence.

    Go on, tell me what you know !

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

  3. #3
    Senior Member
    Join Date
    Jun 1999
    Location
    Fremont, CA, USA
    Posts
    355
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    Do you need to use SetTrap? Why not have a function to handle it. Here is a sample:

    Hope this helps


    ------------------
    David Genrich
    david.genrich@e2open.com
    david@linuxpuppy.net

  4. #4
    Senior Member
    Join Date
    Mar 2000
    Location
    pisctaway, NJ USA
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    What your saying is that at any point a dialog can appear- you want to know exactly when it appears and do some stuff when it does appear.

    It's easy, like you mentioned to close it, however, there is no way for Silk to have some thread waiting on this. Some people have claimed Silk can use threads, just like you want to use it, but I have yet in the many years I use it, to see people demonstrate how to.

    So, your answer is NO, you cannot do something when the dialog appears unless you are specifically looking for it. You can write some code to check for it explicitly after you do something, but nothing like you want.

    Anthony

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

  5. #5
    Senior Member
    Join Date
    Jun 2000
    Location
    Chicago, IL USA
    Posts
    383
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    As David says -- have a function handle it.

    SetTrap() was poorly implemented in SilkTest and is nearly useless as it is.
    We have all wasted a lot of time trying to make it useful.

    A search of the forum for previous discussions on this topic will illustrate this.

    ------------------
    Rob Kapteyn
    Rob Kapteyn, CSTE
    RobKapteyn@gmail.com

  6. #6
    Senior Member
    Join Date
    Aug 2003
    Location
    NY
    Posts
    708
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    Hi All,

    I am facing the same problem and I have quite a good idea which I think might help you all.

    Here is what we can do. Activate SetTrap in TestCaseEnter() and let it throw a user-defined exception number.

    Each testcase would have a do-except. Infact, each single statement would be in the do-except.
    Now, in the except block, first handler would be for our user-defined exception. This would then do the required processing on the popup of the message box(maybe call a function to do that).

    there would be a second exception handler which would handle all other exceptions. Here, the first check would be
    if(myErrorWindow.Exists())
    if this is true, we know what to do.
    else, this is a genuine error and the testcase should abort.

    Sample Pseudo Code(please pardon my usage of C sytax):
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">TestCaseEnter()
    {
    myErrorWindow.SetTrap(&quot;myButon&quot;,30)
    }
    // testcase starts here
    testcase testcase1() appstate none
    {
    do
    {
    all my statements here.
    }
    except
    {
    if ExceptNum() == 30
    {
    myProcessingAfterTrap()
    }
    else
    {
    // this would handle the case if SetTrap fails.
    // since the test would throw an exception if an unexpected window has popped up.
    if myErrorWindow.Exists()
    {
    myErrorWindow.myButton.Click()
    myProcessingAfterTrap()
    }
    // if it reaches here, this is a genuine error
    // let the testcase fail.
    }
    }
    }
    // another function
    void myProcessingAfterTrap()
    {
    // this is the function we would call if the window has popped up.

    }</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">hey, please correct me if I am wrong anywhere since I am also going to use this.

    HTH,
    Harshil

  7. #7
    Senior Member
    Join Date
    Aug 2003
    Location
    NY
    Posts
    708
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    Hi All,

    I guess I was excited unnecessarily. SetTrap() does not raise an exception. Amazingly, it handles it and just prints the error message. I tried passing a function returning string as the last argument, even a pointer to it, but it does not support that.
    Now here is what I had to do.
    I have an enclosing infinite while loop. inside the while there is a do-except block. each statement of my testcase is in the do block. At the end of the do, there ia a break statement. In the except block, I am checking if myErrorWindow exists and doing the necessary processings and continue the while loop. if it does not, that means it is a genuine error, so I am logging exceptdata and again a break from the while.

    Regards,
    Harshil

  8. #8
    Senior Member
    Join Date
    Aug 2003
    Location
    NY
    Posts
    708
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I execute code when trappped dialog is found?

    Originally posted by Harshil:

    Here is what we can do. Activate SetTrap in TestCaseEnter() and let it throw a user-defined exception number.

    Each testcase would have a do-except. Infact, each single statement would be in the do-except.
    Now, in the except block, first handler would be for our user-defined exception. This would then do the required processing on the popup of the message box(maybe call a function to do that).

    there would be a second exception handler which would handle all other exceptions. Here, the first check would be
    if(myErrorWindow.Exists())
    if this is true, we know what to do.
    else, this is a genuine error and the testcase should abort.
    <font size="2" face="Verdana, Arial, Helvetica">I was able to make this piece of code work for me. What I did was, I created a property called myErrorProperty in my MainWin declaration. The Get for this property returns a string and is as follows:
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">[-]Window myMainWin
    [-]property myErrorProperty
    [-] String Get()
    [ ]myFuncForErrorProcessing()
    [ ]return &quot;Error Window Found.&quot;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Now, each call to the settrap would be:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">myErrorPopupBox.SetTrap(myButtonTag,4, myMainWin.myErrorProperty)</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This means, you can call a function through SetTrap [img]images/icons/smile.gif[/img]

    HTH,
    Harshil

 

 

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:12 PM.

Copyright BetaSoft Inc.