SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    May 2005
    Location
    Manchester, UK
    Posts
    122
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    how to check if text exists before action

    I wrote a post some time ago about identiying whether a window exists before performing an action, this I solved with nudging in the right direction by using the following:

    Sub Main ()

    If DotNETForm("My Application",tpAttachNoWait).exists = false Then 'check to see that Application is not there
    restoreblankdb
    Else ' Else my application is there
    closeMyApplication 'so close application first
    restoreblankdb ' then restore database
    End If

    End Sub


    However now I want to know if text exists on the screen before continuing and I'm not sure how to go about doing that using the same method as above.

    I have the following code

    GUIObject("Toptoolbars").Attach
    GUIObject.TextSelect "Export"
    ExecuteCheck "TB_standard_export"

    Where the toolbars are very similar to the ones in the IE explorer window (back button, home icon, Search text etc).

    What I am trying to achieve is write a test to check that all the toolbar icons are available on all screens of our application (as they are still in an inconsistent arrangement), and if it is not, rather than have TP say it cannot attach to 'Export' and then fail, somehow handle this to log it if it does not exist, but also carry on with the script.

    I'm still learning TP and am self taught with no support, so not really very knowledgeable about error handling, as perhaps this is the way to handle this, or I was thinking if I could just do an if statement to get the result.
    Advice on the way to handle this would be much appreciated.
    Thanks
    Using:
    TestPartner 6.3, Visual Tests
    Application under test: Client/Server based, C# .Net App with Infragistics Presentation layer
    Database: SQL 2000/2005

  2. #2
    Advanced Member
    Join Date
    Mar 2002
    Location
    Earth, USA, New York, Western
    Posts
    759
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to check if text exists before action

    zoebuck
    This is what I do, not saying it is the best way:
    1: create an object map of what your looking for.

    <font class="small">Code:</font><hr /><pre>If HTMLImage("ObjectMap", tpAttachNoWait).Exists Then
    TestLog.Comment "GOOD Found It."
    Else
    TestLog.Comment "BAD Not Found."
    End If
    </pre><hr />
    The script will continue with a pass or fail.

    HTH
    BMD

  3. #3
    Senior Member
    Join Date
    Apr 2005
    Location
    Manchester
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to check if text exists before action

    Here's an alternative solution. Not saying its the best way either!

    Sub Main

    GUIObject("Toptoolbars").Attach

    ' Defer error handling if text "Export" is not found and continue with the next statement
    On Error Resume Next

    GUIObject.TextSelect "Export"

    ' If the error description is not blank then you know that an error has been raised i.e. "Export" was not found
    If Not Err.Description = "" Then
    ' Err.description will contain something meaningful like: "Text item 'Export' not found" so you could just log this
    UserCheck "TextSelect", False, Err.Description

    ' You have now handled the error so clear the error object
    Err.Clear
    End If

    ExecuteCheck "TB_standard_export"

    End Sub
    Rob

 

 

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.34%
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 04:35 AM.

Copyright BetaSoft Inc.