Finding objects in a Dojo tree
You can use the dynamic find() API and the dojoTreeExpand() method to find all objects within a Dojo tree control within the application under test.
This example shows you how to use DojoTreeTestObject() to find all objects
within a Dojo tree. You can adapt the code to change the browser if
required.
public void testMain(Object[] args) {
// TODO Insert code here
dojoTreeExpand();
}
public void dojoTreeExpand() {
//Bring the application under test dynamically using startBrowser method and browser as Mozilla Firefox (assuming Firefox is enabled correctly)
//Tips: You change the browser to Internet Explorer in the startBrowser method.
ProcessTestObject process = RationalTestScript.startBrowser(
"Mozilla Firefox", "http://docs.dojocampus.org/dijit/Tree" (http://docs.dojocampus.org/dijit/Tree));
// ProcessTestObject process =
// RationalTestScript.startBrowser("Internet Explorer",
// "http://docs.dojocampus.org/dijit/Tree" (http://docs.dojocampus.org/dijit/Tree));
// Wait for the browser to load completely.
process.waitForExistence();
// The RootTestObject represents a global view of the Application being
// tested. It does not
// represent an actual TestObject in the software under test. it
// provides ways to finding an arbitrary
// TestObject based on properties
RootTestObject to = RootTestObject.getRootTestObject();
// Define Test Object array
TestObject[] dojoControls = null;
for (int i = 0; i <= 10; i++) {
// Performing a find operation and saving the returned object in the TestObject
// array.
dojoControls = to.find(RationalTestScript.atDescendant(".class",
"Html.A", ".className", "show"));
if (dojoControls.length>= 1) {
break;
}
RationalTestScript.sleep(3);
}
// Assigning the first found Test Object to the GUITestObject, and
// perform a click
((GuiTestObject) dojoControls[0]).click();
//Wait enough to load the page completly.
sleep(30);
// Define Test Object array, for a Dojo Tree structure
TestObject[] trees = null;
for (int i = 0; i <= 10; i++) {
// Doing a find operation and saving the returned object in the TestObject
// array.
trees = to.find(RationalTestScript.atDescendant(".dojoclass",
"tree", ".id", "treeOne"));
if (trees.length == 1) {
break;
}
RationalTestScript.sleep(3);
}
//
DojoTreeTestObject dijitTree = new DojoTreeTestObject(trees[0]);
// Dispatched when a tree has 'Continents' as node is expanded
dijitTree.expand(atList(atText("Continents"), atText("North America"),
atText("Mexico")));
// Dispatched when a tree has 'Continents' as node is expanded
dijitTree.click(atList(atText("Continents"), atText("North America"),
atText("Mexico"), atText("Guadalajara")));
sleep(10);
}
}