SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1
    Apprentice
    Join Date
    Sep 2012
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Is it possible to stop the script when it fails?

    Hi I’m Jagadeesh. It would be helpful to me, if anyone can provide me an idea to below problem

    I’ve a scenario in which my script will be executing each test step line by line and for each test step it will report pass and fail result in html result page. If test step result is pass, it will proceed to next test step and further on. Similarly for failed cases it proceeds to next test step and executes it. Is it possible to stop the script when it fails?

    Below is the sample outline script

    Call webEdit_check (“google”,”google”,”nametxtbox”,”xxxx”)
    Call Link_check (strbrowser,strpage,strlink)
    Call WebButton_check (strbrowser,strpage,strWebbutton)

    So according to above script, it will call webEdit function and check whether object is displayed and visible and will enter value in webEdit textbox and result will be written as pass in html result, if all conditions are satisfied.

    After completing above function, now it will call link function and will initiate execution .Here also it will check if object is displayed .If success, it will go to next step. Let us assume link is not visible, here second step in this function fails and so result is written as fail and execution of third function begins( call WebButton_check).

    What I need is entire execution should be stopped as previous test step is failed. Is there any function to run at back end, to stop the execution? When test step fails? Is there any solution to my problem?
    (Please note I’ve multiple scenarios so “Exit Test/Exit function” is not applicable.)

    Functions are

    Function webEdit_check(strbrowser,strpage,strwebEdit,strval ue)
    Testobject=Browser(strbrowser).Page(strpage).WebEd it(strlink)
    If Testobject.exist(10) Then
    blnvisible= testobject.getRoproperty(visible)
    If blnvisible =True Then
    Testobject.set strvalue
    Environment.value(result)=pass
    ‘It will write result to html page
    Call html (“test step is success”,Environment(result))
    Else
    Environment.value(result)=fail
    Call html (“test step is fail”,Environment(result))
    End If
    Else
    Environment.value(result)=fail
    Call html (“test object is not visible fail”,Environment(result))
    End If
    End Function
    Function Link_check(strbrowser,strpage,strLink)
    Testobject=Browser(strbrowser).Page(strpage).Link( strlink)
    If Testobject.exist(10) Then
    blnvisible= testobject.getRoproperty(visible)
    If blnvisible =True Then
    Testobject.click
    Environment.value(result)=pass
    ‘It will write result to html page
    Call html (“test step is success”,Environment(result))
    Else
    Environment.value(result)=fail
    Call html (“test step is fail”,Environment(result))
    End If
    Else
    Environment.value(result)=fail
    Call html (“test object is not visible fail”,Environment(result))
    End If
    End Function

    Function WebButton_check(strbrowser,strpage,strWebButton)
    Testobject=Browser(strbrowser).Page(strpage).WebBu tton(strWebButton)
    If Testobject.exist(10) Then
    blnvisible= testobject.getRoproperty(visible)
    If blnvisible =True Then
    Testobject.click
    Environment.value(result)=pass
    ‘It will write result to html page
    Call html (“test step is success”,Environment(result))
    Else
    Environment.value(result)=fail
    Call html (“test step is fail”,Environment(result))
    End If
    Else
    Environment.value(result)=fail
    Call html (“test object is not visible fail”,Environment(result))
    End If
    End Function

    Function (strverify,Result)
    If Environment(result)=pass Then
    Td.write(<td(strverify)/>td<xxx><td(Result)/>td)
    (please note this is sample, which I typed, it’s just for concept)
    Else
    Td.write(<td(strverify)/>td<xxx><td(Result)/>td)
    End If
    End Function

    If possible please mail (visitjaga@gmail.com) me the solution as in my office I’ve limited access to outside website. I’ll not be able to check immediately. I’ve been strucked with this issue for pass 20 days.

    Thanks& Regard’s
    Jagadeesh Mani
    visitjaga@gmail.com

  2. #2
    Apprentice
    Join Date
    Sep 2012
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Hi Vinod,

    Recovery scenario is applicable only for one scenario ?

    i've 15 scenario's and for each scenario below function will be executed every time

    Call WebEdit_check (“google”,”google”,”nametxtbox”,”xxxx”)

    Call Link_check (strbrowser,strpage,strlink)

    Call WebButton_check (strbrowser,strpage,strWebbutton)

    so if when executing 3 rd scenario, Below step function fails

    Call Link_check (strbrowser,strpage,strlink)

    After above step fails, 3 rd scenario execution should be stopped and exceution of 4 th scenario should begin. Is any logic applicable ?
    Last edited by visitjaga; 12-04-2013 at 12:06 AM.

  3. #3
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,596
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Jagadeesh,
    Could you simplify the code for us? Perhaps make it only 2 function calls with comments at the places where you would like the script to stop on a failure. Im getting lost in the code when I read it.

    Also do you want the script to stop or report a fail and continue to something else?

    Thanks,
    Kevin

  4. #4
    Advanced Member gencke's Avatar
    Join Date
    Feb 2008
    Location
    Seattle, Washington, United States
    Posts
    531
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Perhaps ExitGlobalIteration could be used
    Patience is like bread I say.... I ran out of that yesterday.

  5. #5
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,596
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Note: The Exitxxx comands only work at the action level in QTP 11. I checked and it now also works at the library function level in UFT.

  6. #6
    Advanced Member venu.adhikesevan's Avatar
    Join Date
    Jun 2010
    Posts
    517
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    blnExecution = True

    If blnExecution then
    Call webEdit_check (“google”,”google”,”nametxtbox”,”xxxx”)
    Call Link_check (strbrowser,strpage,strlink)
    Call WebButton_check (strbrowser,strpage,strWebbutton)
    Else
    Skip Execution
    End IF

    Try this logic...If any failure in function call would trigger blnExecution = False
    Venu
    Today is always better than Tomorrow
    My Blog
    My LinkedIn

  7. #7
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Kew Gardens, United States
    Posts
    2,596
    Post Thanks / Like
    Blog Entries
    1
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Venu,
    I don't have QTP in front of me.
    Is skip execution a command or a comment?
    Thanks,
    Kevin

  8. #8
    Super Member
    Join Date
    Dec 2005
    Location
    USA
    Posts
    1,407
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    Environment.value(result)=fail
    Call html (“test step is fail”,Environment(result))
    you can use 'exittest'
    ------------
    Chikki
    when things gets harder ,the harder gets going

  9. #9
    Advanced Member venu.adhikesevan's Avatar
    Join Date
    Jun 2010
    Posts
    517
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Sorry Kevin...Its a comment
    Venu
    Today is always better than Tomorrow
    My Blog
    My LinkedIn

  10. #10
    Member
    Join Date
    May 2011
    Location
    California, US
    Posts
    306
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    You can simply write a exit statement in the reporting function defining fail case, so that when there is fail case and you are reporing the result as fail - it would stop your execution
    --
    Vijay

 

 
Page 1 of 3 123 LastLast

Tags for this Thread

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 9.68%
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 11:58 PM.

Copyright BetaSoft Inc.