I've recently started working with Test Complete and I'm experiencing some odd behaviour when running the code below.
The code's aim is to check whether or not the "New" button is enabled before clicking it. The "New" button resides upon a standard .NET toolbar control.
Before this code runs another function runs that opens the application and logs in. Whilst the application is loading all toolbars are disabled hence the need for this check.
When this code is playing back it is constantly looping even though the toolbar and button are actually active. Now here's the weird part.. if I click on some blank space on the Windows Taskbar and then click back to my application the loop finishes and executes function "CreateNewEstimate".
Any ideas on why this might be happening and how I can correct it?
<font class="small">Code:</font><hr /><pre> function ButtonEnabledCheck()
Toolbar = Aliases.tbrGMX4Standard;
// Check if Button with index 0 ("New") is enabled. True = run CreateNewEstimate, False = loop
P.S. I apologise if this has been covered elsewhere but I couldn't find any posts relating to it. Oh and if anyone can suggest a better way to check for enabled/disabled toolbars please let me know! [img]/images/graemlins/laugh.gif[/img]
Re: Issue with checking wEnabled method of an obje
The problem is caused by the fact that the Aliases.tbrGMX4Standard object does not exist when you are trying to retrieve it. TestComplete assigns a wrapper aliased object to the Toolbar variable and when you try to address the variable, the script fails, because the underlying object does not exist. I recommend that you call the RefreshMappingInfo method before retrieving the problematic object and replace the Toolbar.Refresh method call with the Toolbar.RefreshMappingInfo method (see the "RefreshMappingInfo Method" help topic for more information). If this suggestion does not help you solve the problem, please follow the steps below:
1. Set a breakpoint on the problematic line of your code.
2. Launch your script. When the script stops on the breakpoint, go to the Object Browser and use the Object Properties window to retrieve the problematic object's properties. Please see the "Exploring an Application in the Object Browser" help topic for more information.
3. Check whether the actual values of the object's properties correspond to those used in your Name Mapping scheme. If they do not, please modify your Name Mapping scheme and check whether the problem can be reproduced.
4. If the problem can be reproduced even if the values coincide and the object is present on your screen, please zip your entire TestComplete project suite folder along with the log of the failed test execution and send us the archive via our Contact Support form (http://www.automatedqa.com/support/message.asp).