Forum Discussion
Christopher,
As far as I can see, the problem is in the page size and the search approach you are using. You are searching in the entire page, and it takes the Find method some time to go through all the elements. You can try specifying more precise search conditions and narrowing the search range.
* In your code, you are using the * wildcard, for instance, in the following statement:
page.NativeWebObject.Find("id", "*_saveNextPrevButtonsTop_questionnaireButtons_btm_right", "a").disabled == false
This approach takes longer than if using a string without wildcards as the Find method has to check all the variants that match the wildcard string. The value you are searching for seems to be quite unique. Is it necessary to use the wildcard? I'd suggest to get rid of wildcards where they are not necessarily needed.
* The Find method returns a wrapper test object that TestComplete provides for the page's sought-for element. In many cases, you don't use the wrapper's methods and properties, but use methods and properties of HTML elements. In this case, you can obtain these elements by using a statement like this --
Page(…).Application.Document.getElementById('id_of_desired_object')
For example, instead of --
page.NativeWebObject.Find("id", "*_element_id", "a").disabled == false
you can use something like this --
page.Application.Document.getElementById('my_element_id').disabled == false
When you obtain a page's elements in this way, you don't have access to TestComplete's methods and properties like Click or HoverMouse. However, you don't need them here.
Statements that use TestComplete's Exists method can be replaced with statements that compare an object with null. For example, instead of --
if (page.NativeWebObject.Find("id", "*_txtCommentsTab_ifr", "iframe").Exists)
you can use something like this --
if (page.Application.Document.getElementById('id') != null)
* If you need to simulate user actions on an element, you need to use the Find method. However, in this case, you can try narrowing the search range. Judging by your code, you are searching through the entire page. Is it possible to get an object that is a container for the sought-for elements (e,g. table or div) and then use Find to search for the needed elements in it?
Related Content
- 12 years ago
- 9 years ago
- 8 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 7 days ago