Test Automation of Natural for Ajax Applications Part II

1 Testing the Helloworld Sample

Let’s have a look at the helloworld.xml page layout of the njxdemos. The most interesting controls for automated tests are the FIELD control and the BUTTON control. How to test the FIELD control we have already described above. Testing the BUTTON control is very similar. In the BUTTON control, a method property is set, but again no explicit testtoolid property is set. For a BUTTON control, a testtoolid with the value of the method property will be automatically generated as shown in the HTML snippet below. Again, don’t worry about the HTML details, just keep focused on the testtoolid attribute.

<button type="button" id="B_17" testtoolid='onHelloWorld'
           style="width: 185px; height: 80px;" name="CC"
        class="BUTTONInput">


With the tool Selenium, for instance, you can locate the FIELD and the BUTTON control using a corresponding XPATH expression which contains the testtoolid value. This XPATH expression can be passed to the Selenium locator org.openqa.selenium.By.ByXPath:

By myfieldlocator = new ByXPath(".//*[@testtoolid='yourname"]");
By mymemthodlocator = new ByXPath(".//*[@testtoolid='onHelloWorld"]");

See http://docs.seleniumhq.org/ for more information about the Selenium Java API.

In some cases, you don’t want to use the valueprop of a control as testtoolid but instead specify your own testtoolid. Examples for this are layouts in which several controls are bound to the same Natural data field. To do so, simply set an explicit testtoolid property for these controls:


<input id="F_13" name="CC" class='FIELDInputEdit'                        testtoolid='myowntesttoolid' type="text" style="width: 185px;">

2. Testtoolids for Complex Controls

For complex controls a single testtoolid is not enough to locate the single parts of the control. The following table provides examples for the most common XPATH expressions for some complex controls.

Control

testtoolid

XPATH

ICONLIST

testtoolid="myiconlist"

.//*[@testtoolid='myiconlist0'],

.//*[@testtoolid='myiconlist1'],…

BUTTONLIST

testtoolid="mybuttonlist"

.//*[@testtoolid='mybuttonlist0'],

.//*[@testtoolid='mybuttonlist1'],…

ROWTABLEAREA2

testtoolid="lines"

.//*[@testtoolid='lines_table']

Rows/Cols:

.//*[@testtoolid=’lines.items[0].

      <col1testtoolid>’]

.//*[@testtoolid=’lines.items[0].

      <col2testtoolid>’]…

.//*[@testtoolid=’lines.items[1].

      <col1testtoolid>’]

.//*[@testtoolid=’lines.items[1].

      <col2testtoolid>’]…

ROWTABSUBPAGES

testtoolid="mytabs"

.//*[@testtoolid='mytabs0'],

.//*[@testtoolid='mytabs1'],…

MULTISELECT

testtoolid="mychoice"

XPATH for entries:

.//*[@testtoolid='mychoice0'],

.//*[@testtoolid='mychoice1'],…

XPATH for buttons:

.//*[@testtoolid='mychoicebutton0'],

.//*[@testtoolid='mychoicebutton1'],

.//*[@testtoolid='mychoicebutton2'],

.//*[@testtoolid='mychoicebutton3']

Also in complex controls you don’t need to explicitly set the testtoolid property in the page layout. If you don’t specify any testtoolid, then the corresponding *prop properties like valueprop, griddataprop, iconlistprop, pagesprop…. will be used.

Here is the list from above when not specifying a testtoolid explicitly:

 

Control

*prop

XPATH

ICONLIST

iconlistprop="myiconlist"

.//*[@testtoolid='myiconlist0'],

.//*[@testtoolid='myiconlist1'],…

BUTTONLIST

buttonlistprop="mybuttonlist"

.//*[@testtoolid='mybuttonlist0'],

.//*[@testtoolid='mybuttonlist1'],…

ROWTABLEAREA2

griddataprop="lines"

.//*[@testtoolid='lines_table']

Rows/Cols:

.//*[@testtoolid=’lines.items[0].

      <col1testtoolid>’]

.//*[@testtoolid=’lines.items[0].

      <col2testtoolid>’]…

.//*[@testtoolid=’lines.items[1].

      <col1testtoolid>’]

.//*[@testtoolid=’lines.items[1].

      <col2testtoolid>’]…

ROWTABSUBPAGES

pagesprop="mytabs"

.//*[@testtoolid='mytabs0'],

.//*[@testtoolid='mytabs1'],…

MULTISELECT

valueprop="mychoice"

XPATH for entries:

.//*[@testtoolid='mychoice0'],

.//*[@testtoolid='mychoice1'],…

XPATH for buttons:

.//*[@testtoolid='mychoicebutton0'],

.//*[@testtoolid='mychoicebutton1'],

.//*[@testtoolid='mychoicebutton2'],

.//*[@testtoolid='mychoicebutton3']

 

 

Related Assets:

Test Automation of Natural for Ajax Applications Part I