FindElement - web automation method

Connects a web automation Element to an IHTMLElement that matches a tag-name and verifies a list of Search Conditions.

Applies to:
Browser, Frame, Element
  var e = obj.FindElement("tag_name", Search conditions);
This method accepts a variable number of Search Condition arguments. Any HTML attribute is accepted in search conditions. Text is also accepted as attribute in search conditions, in this case the text of the HTML element is used in search. A special zero-based index attribute is available in search condition specifying the ordinal position in the collection of objects generated by the remaining search conditions. If no search condition is provided then the first element that matches the tag_name is returned.
The method returns an Element IE automation object that matches the search condition arguments and has the specified tag_name. It provides programmatic control over the underlying IHTMLElement native object exposed by IE browser. If no element verifies the search conditions, then null is returned.
In case of an error the method throws a script exception and the lastError property of the core object is set as follows:
The time allocated for search is specified by the searchTimeout property. The search is affected by useRegExp property. If loadTimeout is not zero, then the method waits the browser objects to be completely loaded in the amount of time specified by the property. If the timeout has expired the lastError property is set to LOAD_TIMEOUT_ERROR. In this case, if loadTimeoutIsError property is true, then a IE macro exception is thrown.

If the container object is a Browser, then the method searches the element in all the frame and iframe DOM hierarchy of the browser. If the container object is a Frame, then the method searches the element in all the frame and iframe DOM hierarchy of the container frame. If the container object is an Element, then the method searches the element in all HTML DOM hierarchy of the container.

The target HTML element can be inside frames/iframes loaded from various domains. Twebst Web Automation Library bypass all cross-frame scripting security restrictions (see: When IHTMLWindow2::get_document returns E_ACCESSDENIED and When IHTMLWindow2.document throws UnauthorizedAccessException).
var coreObj = new ActiveXObject("Twebst.Core");
var browser = coreObj.StartBrowser("");

var element = browser.FindElement("a", "text=Download");
See also:
Element | FindChildElement | loadTimeout | searchTimeout | useRegExp

© 2014 CodeCentrix Software. All rights reserved.