FindAllElements - web automation method

Searches inside a container web automation object, the collection of all HTML elements that match a tag-name and verifies a list of Search Conditions.

Applies to:
Browser, Frame, Element
  var elementList = obj.FindAllElements("tag_name", Search conditions);
Arguments:
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. If no search condition is provided, then the collection of all elements that match the tag_name is returned.
Remarks:
The method returns an ElementList web automation object containing HTML elements that match the search condition arguments and have the specified tag_name. If no element verifies the search conditions, then an empty list is returned. In case of an error the method throws a web macro 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 script exception is thrown.

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

The target HTML elements 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).
Example:
// Display all the links in a web page.
var coreObj = new ActiveXObject("Twebst.Core");
var browser = coreObj.StartBrowser("http://www.codecentrix.com/");

var textToDisplay = "";
var anchorList    = browser.FindAllElements("a");
for (i = 0; i < anchorList.length; ++i)
{
	textToDisplay += anchorList(i).nativeElement.innerText + "\n";
}
WScript.Echo(textToDisplay);
		
See also:
Element | ElementList | FindChildrenElements | loadTimeout | searchTimeout | useRegExp

© 2014 CodeCentrix Software. All rights reserved.