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
Else ' Else my application is there
closeMyApplication 'so close application first
restoreblankdb ' then restore database
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.
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.
TestPartner 6.3, Visual Tests
Application under test: Client/Server based, C# .Net App with Infragistics Presentation layer
Database: SQL 2000/2005
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."
TestLog.Comment "BAD Not Found."
The script will continue with a pass or fail.
Here's an alternative solution. Not saying its the best way either!
' Defer error handling if text "Export" is not found and continue with the next statement
On Error Resume Next
' 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