Forum Discussion
AlexKaras
11 years agoChampion Level 3
Hi Alexandra,
In TestComplete, when UI (or special stub) object exists (or existed earlier and was referenced by test code) it always has Exists property. So check of object.WaitProperty("Exists") is useless and can be replaced with just object.Exists.
The reason of the sporadic error messages in the log in your case may be because the given object might not be created by the tested application yet while your test code already attempts to use it.
SmartBear pays constant attention to TestComplete's performance, so quite often guys are reporting that they had no problems with their test while using, say, version 9, but started to get 'object not found' error after upgrading to version 10.
Most often the reason is improved performance of test execution.
As an example, consider this scenario: your test clicks on some link in the web application, this causes some text (label) to be shown and you need to log the contents of this label.
Consider this pseudocode:
page.parentObject.Link.Click
If (page.parentObject.Label.Exists) Then
Log.Message(page.parentObject.Label.innerText)
Else
Log.Error ...
End If
This code will work if your application is fast enough (or test execution is slow enough:) ) and the label object is created almost immediately after the link is clicked.
Otherwise, you will get the 'object not found' error on this line:
If (page.parentObject.Label.Exists) Then
The reason of the error will be that test code tries to get the .Exists property of the object (Label) that is not created yet.
To avoid the error, correct actions sequence must be like this:
-- Click the link;
-- Wait for the target object for some reasonable time period;
-- Check if the object or its stub (see TestComplete's help for WaitXXX() functions for more details) was created;
-- Use the object if it was created.
Using the same pseudocode, the modified test will look like this:
page.parentObject.Link.Click
Set oLabel = page.parentObject.WaitLabel(5000) ' wait up to 5 secs for the label to be created
If (oLabel.Exists) Then
Log.Message(oLabel.innerText)
Else
Log.Error("Label object was not created within 5 seconds")
End If
Hope, this will help...
In TestComplete, when UI (or special stub) object exists (or existed earlier and was referenced by test code) it always has Exists property. So check of object.WaitProperty("Exists") is useless and can be replaced with just object.Exists.
The reason of the sporadic error messages in the log in your case may be because the given object might not be created by the tested application yet while your test code already attempts to use it.
SmartBear pays constant attention to TestComplete's performance, so quite often guys are reporting that they had no problems with their test while using, say, version 9, but started to get 'object not found' error after upgrading to version 10.
Most often the reason is improved performance of test execution.
As an example, consider this scenario: your test clicks on some link in the web application, this causes some text (label) to be shown and you need to log the contents of this label.
Consider this pseudocode:
page.parentObject.Link.Click
If (page.parentObject.Label.Exists) Then
Log.Message(page.parentObject.Label.innerText)
Else
Log.Error ...
End If
This code will work if your application is fast enough (or test execution is slow enough:) ) and the label object is created almost immediately after the link is clicked.
Otherwise, you will get the 'object not found' error on this line:
If (page.parentObject.Label.Exists) Then
The reason of the error will be that test code tries to get the .Exists property of the object (Label) that is not created yet.
To avoid the error, correct actions sequence must be like this:
-- Click the link;
-- Wait for the target object for some reasonable time period;
-- Check if the object or its stub (see TestComplete's help for WaitXXX() functions for more details) was created;
-- Use the object if it was created.
Using the same pseudocode, the modified test will look like this:
page.parentObject.Link.Click
Set oLabel = page.parentObject.WaitLabel(5000) ' wait up to 5 secs for the label to be created
If (oLabel.Exists) Then
Log.Message(oLabel.innerText)
Else
Log.Error("Label object was not created within 5 seconds")
End If
Hope, this will help...
Related Content
- 3 years ago
- 4 years ago
- 6 years ago
Recent Discussions
- 15 hours ago