如何点击ITestDataTreeNode中的一个node
我要点击一棵树 我用ITestDataTreeNode[] nodes = ((ITestDataTree)targetTree.getTestData("tree")).getTreeNodes().getRootNodes();
获得了树上的一些nodes
但是因为nodes的名字有重复
请问怎样能点到想要点击的node
我想通过index来点击,但是返回的nodes[]要怎样调用.click或者其他选择的方法 急啊 哪位朋友给小弟指点一下 顶一下
[ 本帖最后由 dudejava 于 2007-5-23 18:01 编辑 ] ScrollGuiSubitemTestObject objectTree = new ScrollGuiSubitemTestObject(getMappedTestObject(treeName));
int itemHeight = ((Integer) objectTree.getProperty("itemHeight")).intValue();
int headerHeight = ((Integer) objectTree.getProperty("headerHeight")).intValue();
Rectangle clientArea = (Rectangle) objectTree.getProperty("clientArea");
int clientAreaHeight = (int) clientArea.getHeight();
int viewableArea = ((clientAreaHeight - headerHeight) / itemHeight) - 2;
int pointToClick = (int) (itemHeight * 1.5);
ITestDataTree objectTreeData = (ITestDataTree) objectTree.getTestData("tree");
ITestDataTreeNode [] objectTreeRootNodes = ((ITestDataTreeNodes) objectTreeData.getTreeNodes()).getRootNodes();
for (int i = 0; i < objectTreeRootNodes.length; i++) {
objectTree.doubleClick(atPoint(0, pointToClick));
// Perform whatever activity is needed
// Viewable area is a number of rows; if the current row is greater, scroll
if (i > viewableArea) {
objectTree.scrollLineDown();
} else {
pointToClick += itemHeight;
}
} 通过位置int pointToClick ,来定位节点 原帖由 hugh_1982 于 2007-5-10 14:59 发表 http://bbs.51testing.com/images/common/back.gif
我要点击一棵树 我用
ITestDataTreeNode[] nodes = ((ITestDataTree)targetTree.getTestData("tree")).getTreeNodes().getRootNodes();
获得了树上的一些nodes
但是因为nodes的名字有重复
请问怎样能点到想要 ...
getRootNodes
问一下,怎么能获得整个tree的nodes。为什么我只能获得根节点的,返回的数组长度是1,root也只是只根节点吧? Hi,hugh_1982!
Following example may be helpful to you.
public void testMain (Object[] args)
{
//Declare variables for tree
ITestDataTree cdTree;
ITestDataTreeNodes cdTreeNodes;
ITestDataTreeNode[] cdTreeNode;
//Variables to hold tree data
cdTree = (ITestDataTree)tree2Tree().getTestData("tree");
cdTreeNodes = cdTree.getTreeNodes();
cdTreeNode = cdTreeNodes.getRootNodes();
//Print out total number of nodes
System.out.println ("Tree Total Node Count: " +
cdTreeNodes.getNodeCount());
System.out.println ("Tree Root Node Count : " +
cdTreeNodes.getRootNodeCount());
//Iterate through tree branches; this is a recursive method.
for (int i = 0;i<cdTreeNode.length;++i)
showTree(cdTreeNode, 0);
}
void showTree(ITestDataTreeNode node, int indent)
{
//Recursive method to print out tree nodes with proper indenting.
//Determine number of tabs to use - to properly indent tree
int tabCount = ( indent < tabs.length() ? indent :
tabs.length() );
//Print out node name + number of children
System.out.println(tabs.substring(0, tabCount) +node.getNode() + " (" + node.getChildCount() + " children)" );
//Determine if node has children; recursively call this same
//method to print out child nodes.
ITestDataTreeNode[] children = node.getChildren();
int childCount = ( children != null ? children.length : 0 );
for ( int i = 0; i < childCount; ++i )
showTree(children, indent+1);
} 原帖由 nanchi 于 2008-1-9 23:07 发表 http://bbs.51testing.com/images/common/back.gif
...
showTree(cdTreeNode, 0);
...
void showTree(ITestDataTreeNode node, int indent){
...
int tabCount = ( indent < tabs.length() ? indent :tabs.length() );
...
}
还是几个问题啊:
showTree(cdTreeNode, 0)//传的是数组参数,常量0,这个0应该是 变量 i 吗。。
void showTree(ITestDataTreeNode node, int indent)//接收参数却不是数组。。
tabs.length()//tabs是没有定义
[ 本帖最后由 tthhbbandy 于 2008-1-16 11:32 编辑 ]
页:
[1]