`
plkong
  • 浏览: 177549 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Rational Functional Tester Java jTree relative references

 
阅读更多

Problem(Abstract)

The recording in IBM® Rational® Functional Tester of a Java™ jTree has a complication. This technote demonstrates a way to use relative paths to access jTree objects.

Symptom

The recording generates the following code.

 


jTree().doubleClick(atPath("F3 - Clients->HUIZINGA, JOHAN->Client Details"));      ​

If the item of HUIZINGA, JOHAN changes, the playback fails.

 

Resolving the problem

The Java method getTreeHierarchy converts the above line of code to the following code.

 


jTree().doubleClick(atPath(getTreeHierarchy(j​Tree(),​​ "Client Details")));​


This code puts the same path as above and does not consider the full hierarchy. The hierarchy can be dynamic. The following code helps you to search a tree for the parent hierarchy.


public String getTreeHierarchy(TestObject treeName, String searchTree) { ​

/**​
 * Description : Search a tree for the parent hierarchy.​
 *   We need to use this within atPath statements with trees​
 *   in the situation where the parents may be DYNAMIC.​
 *   For example, if you had <Client Name> -> Licence where of course​
 *   Client Name is going to change, you simply call​
 *   getTreeHierarchy(jTree(), "Licence") - or similar -​
 *   and it works out the parent(s). In this case you don't​
 *   have to worry.​
 *   This is reproducible, because RFT does not allow you to​
 *   say click on a "child" node, you must specify the full​
 *   path.​
 * ​
 * Parameters  : treeName   - the tree which you want to search ​
 *    you will need () at the end of the tree​
 *   searchTree - the node you are looking for​
 * ​
 * Returns     : Full path of tree as a string.​
 * ​
 */​

//Declare variables for tree​
ITestDataTree  treeToSearch;​
ITestDataTreeNodes  treeToSearchTreeNodes;​
ITestDataTreeNode[] treeToSearchSpecificNode;​
String foundHierarchy = "";​

       //Variables to hold tree data​
treeToSearch = (ITestDataTree) treeName.getTestData("tree");​
treeToSearchTreeNodes = treeToSearch.getTreeNodes();​
treeToSearchSpecificNode =treeToSearchTreeNodes.getRootNodes();​

//Iterate through tree branches; this is a recursive method.​
for ( int i = 0; i < treeToSearchSpecificNode.length; ++i )​
{​
foundHierarchy = searchTree(treeToSearchSpecificNode[i], searchTree, "");​
if (foundHierarchy != "")​
  break;​
}​

return foundHierarchy;​
}​

 private String searchTree(ITestDataTreeNode node, String searchText, String hierarchy) {​
/**​
 * Description : Searches the tree for a specific node​
 *               and calls itself recursively to traverse the tree.​
 *  Called by getTreeHierarchy.​
 * ​
 * Parameters  : node     - the tree node to traverse​
 *    searchText - the node to look for​
 *    hierarchy - current parent hierarchy above this node ​
 * ​
 * Returns     : The tree hierarchy that has been found.​
 * ​
 */​

String nodeSeparator = "->";​
String searchResult  = "";​

// If we are at the top level of the hierarchy, don't prepend nodeSeparator​
if (hierarchy == "")​
hierarchy = node.getNode().toString();​
else​
  hierarchy += nodeSeparator + node.getNode().toString();​

// If we have found our target Node record the current hierarchy ​
  if (node.getNode().toString().startsWith(searchT​ext))​​ {​
  searchResult = hierarchy;​
  }​
  else​
  {​
  // only bother doing this if we havent found our target Node​
// Determine if node has children and if so,​
// 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 ) ​
  {​
  searchResult = searchTree(children[i], searchText, hierarchy);​

if (searchResult != "")​
  break;​
}​
}​

return searchResult;​
}​





COMMENT
Alternatively you can use equalsIgnoreCase in searchTree if startsWith fails.


DISCLAIMER:
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

分享到:
评论

相关推荐

    Rational Functional Tester for Terminal Application

    Rational Functional Tester (简称RFT) 是一款强大的自动化测试工具,广泛应用于各种应用场景中,包括Web、Java、.NET、Flex以及终端应用程序等。它支持多种脚本语言,并具备智能识别功能,能够帮助测试人员快速创建...

    详解IBM Rational Functional Tester 的工作原理.docx

    Rational Functional Tester (RFT) 是一款强大的自动化测试工具,主要应用于软件功能测试。它能够操控各种类型的被测应用程序,包括基于 Java、.Net、HTML 以及特定平台如 Siebel、SAP 和 Flex 的应用。要理解 RFT ...

    IBM Rational Functional Tester

    改进 Rational Functional Tester 启动应用程序的过程 基于Rational 的BS 架构软件自动化测试研究 使用Rational Functional Tester 完成自动化功能测试 详解IBM Rational Functional Tester 的工作原理

    Essentials of IBM Rational Functional Tester, Java Scripting

    ### IBM Rational Functional Tester (RFT) 与 JavaScripting 基础 #### 课程概述 IBM Rational Functional Tester(简称RFT)是一款强大的自动化测试工具,主要用于功能和回归测试。它支持多种应用程序和技术栈,...

    Rational Functional Tester - Tips and Tricks

    Rational Functional Tester,曾被称为“Rational XDE Tester”,是一款针对Web、Java、.NET、Siebel、基于终端的应用以及即将支持的SAP应用进行自动化功能性与回归测试的工具。其关键优势在于: 1. **维护最小化**...

    IBM Rational Functional Tester简介

    IBM Rational Functional Tester 简介 IBM Rational Functional Tester(RFT)是一款先进的、自动化的功能和回归测试工具,它适用于测试人员和 GUI 开发人员。使用 RFT,可以帮助测试人员轻松地完成自动化的功能...

    Internet Explorer针对Rational Functional Tester性能异常,出现错误或无法启用

    在使用IBM Rational Functional Tester(RFT)进行自动化测试时,可能会遇到与Internet Explorer浏览器的兼容性和性能问题。本文将详细探讨这些问题的症状、原因以及解决方法。 症状主要包括:在录制脚本时,...

    使用 Rational Functional Tester 给开发人员带来的好处

    如果您利用 IBM Rational Functional Tester 记录测试用例,那么您可以在通常所花费的一小部分时间内重新执行整套的回归测试。本文将向您介绍可以使用 IBM:registered: Rational:registered: Functional Tester 来...

    Rational Functional Tester

    Rational Functional Tester (RFT) 是一款强大的自动化测试工具,尤其适用于测试复杂的业务流程和用户界面,例如Windows和.NET应用程序。RFT允许测试人员录制、编辑和执行测试脚本,以确保软件的质量和稳定性。 本...

    IBM Rational Functional Tester 活用ガイド

    根据提供的文档信息,我们可以提取并总结出关于IBM Rational Functional Tester (RFT) 的一系列关键知识点。以下内容将详细解释文档中的各个章节,并提供对每个部分的深入理解。 ### 当指南的位置与价值 #### 1. ...

    Internet Explorer针对Rational Functional Tester性能异常,出现错误或无法启用.docx

    在使用IBM Rational Functional Tester(RFT)进行自动化测试时,可能会遇到一些性能异常,尤其是在录制或播放基于Internet Explorer的脚本时。这个问题涉及到RFT与IE浏览器的交互,具体表现为响应速度缓慢,脚本...

    Rational_Functional_Tester_的高效测试自动化技巧

    "Rational Functional Tester 的高效测试自动化技巧" Rational Functional Tester 是一种强大的测试自动化工具,旨在帮助开发者和测试者更好地进行自动化测试。在这篇文章中,我们将讨论如何使用 Rational ...

    rational functional tester -- IBM red book

    ### Rational Functional Tester (RFT) – IBM Red Book #### 引言 IBM Rational Functional Tester (RFT) 是一款面向对象的自动化测试工具,它能够帮助用户对多种应用程序进行测试。该工具支持通过录制来快速生成...

    Rational Performance Tester Install

    4. Java Development Kit (JDK):安装最新版本的JDK,因为Rational Performance Tester依赖于Java运行环境。 二、下载安装包 从IBM官方网站获取Rational Performance Tester的安装包,通常为.exe或.iso格式。确保...

    IBM Rational Performance Tester

    IBM Rational Performance Tester

    Rational Performance Tester 8.1

    《深入解析Rational Performance Tester 8.1》 Rational Performance Tester(RPT)是IBM公司推出的一款强大的性能测试工具,主要用于模拟大量用户并发访问应用程序,以此来检测系统在高负载情况下的性能、稳定性...

    如何利用Rational Performance Tester进行性能测试

    本文将详细介绍如何使用IBM的Rational Performance Tester进行性能测试,包括其基本概念、工作原理以及实施步骤。 Rational Performance Tester是IBM Software Group推出的一款强大的性能测试工具,它提供了一个...

Global site tag (gtag.js) - Google Analytics