by  Adam S Tuesday, January 20, 2015
Often you want to be able to query for the child elements on a web page that are dynamically created and therefore not good candidates for LEARNing individually. This article explains how you can use the dynamic XPATH methods of Rapise to accomplish this task.

If we consider the following sample web page:

http://echoecho.com/htmlforms09.htm

This has the following checkboxes:

In this example instead of learning the three checkboxes, we just position the mouse over the entire cell and LEARN that:

Assuming that this Cell is learned in Rapise with the name 'Cell', you can use the following code to dynamically query the child objects of the cell:

function Test()
{

 Tester.Message('ChildrenCount = ' + SeS('Cell').DoDOMChildrenCount());
 var /**Array*/items = SeS('Cell').DoDOMQueryXPath('*');
 for (var /**Number*/i = 0; i < items.length; i++)
 {
  var item = items[i];
  Tester.Message('Tag=' + item.GetTag() + ', Name=' + item.GetName() + ', Value=' + item.GetValue() + ', Checked=' + item.GetChecked());
 }
}

When this is executed, it generates the following report:


Article Info
  • Last Updated: 1/20/2015
  • Article ID: KB109
  • Views: 1204