IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope: Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    
跳转到主要内容

developerWorks 中国  >  Rational  >

使用 Rational Functional Tester V7.0 测试 Mozilla Firefox 应用程序

developerWorks
文档选项

未显示需要 JavaScript 的文档选项


级别: 初级

Michael Kelly (Mike@MichaelDKelly.com), 咨询师, www.MichaelDKelly.com

2007 年 3 月 30 日

IBM Rational Functional Tester 7.0 支持使用 Mozilla Firefox 对 HTML 应用进行测试。这篇文章阐述了一些新的能力。

Rational Functional Tester 提供了良好的脚本语言和开发环境——在 Eclipse 框架下的 JAVA 或者在 Microsoft Visual Studio .NET 开发环境下的 Microsoft Visual Basic .NET 。那就意味着无论您的开发小组成员选择什么样的语言或者平台,在您进行自动化测试时都能够将他们整合成一个整体,并利用一些专家的经验。

在这篇文章中,我们将会看到当 Mozilla Firefox2.0 版本中的 HTML 应用程序在 Java 环境中被执行时,利用 Rational Functional Tester v7.0 进行测试的情况。不要着急,如果您使用.NET,基本上也是一样。

注意:尽管 Rational 软件也可以与其它操作系统和浏览器一起工作,但是作者在写这篇文章时却使用了 IBM Rational Functional Tester 7.0 版本,Microsoft® Windows® XP Professional 操作系统(Sp2),以及 Mozilla Firefox V2.0。

在 Mozilla Firefox 2.0 版本里测试 HTML 应用程序

在这篇文章中您将完成一个例子。这个例子达到了让您观察在 Mozilla Firefox 2.0 中的测试情况以及说明 Rational Functional Tester 基本特征的双重目的。关于这个例子,您将在 www.BookPool.com 定购一本关于 Java™的书。

  1. 开始使用 Rational Functional Tester,打开一个现有的项目。
  2. 点击 Record a Functional Test Script给这个脚本输入一个名称。 (参见 图 1。)

图1.显示 Record a Functional Test Script 的屏幕
Figure 1. Record a Functional Test Script screen display

  1. 点击Finish 开始记录。您在图 2中看到的这个 Recording 窗口将会打开。

图2. Recording 窗口
Figure 2. Recording window

  1. 点击 Start Application,将会打开 Start Application 窗口,如图 3所示。

图3. Start Application 窗口
Figure 3. Start Application window

  1. 将 URL 地址添加到应用程序名称列表中,点击 Edit Applications List... 按钮。
  2. 图 4所示的Application Configuration Tool 窗口中,点击 Add... 按钮。

图4. Application Configuration Tool 窗口
Figure 4. Application Configuration Tool window

  1. Add Application 窗口中(图5),指向Select kind of application 并选择HTML Application。然后点击 Next

图5. Add Application窗口
Figure 5. Add Application window

  1. Select HTML application中(图6),仍然在 Add Application 窗口,输入 URL 地址www.BookPool.com,然后点击Finish

图6.在 Select HTML application 视图添加 URL 地址。
Figure 6. Add the URL in the Select HTML application view

  1. Edit Application InformationApplication Configuration Tool 窗口(图 7)您应该在 Applications 下可以看到 BookPool URL 地址列在其中。
  2. 确保在 Browser域中选择了 Mozilla Firefox

图7. Edit Application Information 窗口
Figure 7. Edit Application Information window

  1. 点击 Finish
  2. 回到 Start Application 窗口,并在 Application Name 字段中选择这个 URL 地址,然后点击 OK。 这个 BookPool.com 网站将在您的浏览器中打开。
  3. 在网站上的 Search 窗口输入Java,搜寻关于 Java 的书籍 (图 8)。

图8.搜寻网站查找关于 Java 的书
Figure 8. Search the Web site for a book about Java

  1. search results page中 ,通过点击Add to Basket first book listed 添加到您的购物车中(图 9)。

图 9. 从搜索结果中选择第一本书添加到您的购物栏中
图 9. 把您搜索结果中第一本书添加到您的购物车中

  1. 您可以看看您购物车中的书,但是要确保这本书在您的购物车中,并进入验证点。首先,点击Insert Verification Point or the Action Command 按钮。这样会打开Verification Point and Action Wizard,您可以在图 10中看到。

图10. Verification Point and Action Wizard 屏幕
Figure 10. Verification Point and Action Wizard screen

  1. 利用 Object Finder, 选择您想要定购的书籍列表中的data。 您可以看到整个浏览器周围有一个红色的边框,如图 11所示。(接受缺省设置,否则另选其它)

图11.用 Object Finder 来选择您想要定购的书
Figure 11. Use the Object Finder to select the book that you want to order

  1. Verification Point and Action Wizard 中选择 Perform Properties Verification Point (图 12),然后点击Next。

图12. Verification Point and Action Wizard
Figure 12. Verification Point and Action Wizard

  1. Insert Properties Verification Point Command 窗口中图 13),确保 Include Children 的设置是 All,然后点击 Next

图13. Insert Properties Verification Point Command 窗口
Figure 13. Insert Properties Verification Point Command window

  1. 下一个屏幕(图 14) 将会提示您选择属性使其包含在验证点中。根据导向,通过 Test Objects 树指向一个包含您所选择的书的 HTML 表格,然后 检查那个框。
  2. 然后在 Property 列表中检查这个框。

图14. Verification Point Data 窗口
Figure 14. Verification Point Data window

  1. 点击 Finish ,关闭浏览器,并停止记录。

Rational Functional Tester 现在可以产生一个看起来跟列表 1屏幕显示中十分相似的一个脚本。


列表1. 由 Rational Functional Tester 产生的脚本
				 
import resources.AddToCartHelper;

import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.SAP.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;

/**
 * Description   : Functional Test Script
 * @author Michael
 */
public class AddToCart extends AddToCartHelper
{
	/**
	 * Script Name   : AddToCart
	 * Generated     : Nov 5, 2006 2:53:22 PM
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 5.1  Build 2600 (S)
	 * 
	 * @since  2006/11/05
	 * @author Michael
	 */
	public void testMain(Object[] args) 
	{
		startApp("www.BookPool.com");
		
		// Window: firefox.exe: Bookpool Discount Computer Books. Welcome!
		texttext().click(atPoint(78,10));
		bookpoolDiscountComputerBooksW().inputChars("Java");
		httpGBookpoolComHpSearch_btnGi().click(atPoint(24,11));
		
		// Window: firefox.exe: Bookpool: Books Found - Mozilla Firefox
		cellwin().click(atPoint(0,0));
		
		// Window: firefox.exe: Bookpool: Shopping Basket - Mozilla Firefox
		cellwin2().performTest(Cell_standardVP());
		bookpoolShoppingBasketMozillaF(ANY,MAY_EXIT).click(CLOSE_BUTTON);
	}
}

现在,可以运行您记录的这个脚本了。

  1. 打开这个脚本,点击工具条上的 Run Functional Test Script 按钮。这样就打开了如 图 15显示的Select Log窗口。

图15. Select Log 窗口
Figure 15. Select Log window

  1. 点击Finish 运行这个脚本。

当脚本运行时您可以看到 Playback 窗口(图 16)。 如果因为某种原因这个脚本停止运行,这个窗口会给您提示发生了什么。


图16. Playback 窗口
Figure 16. Playback window

当脚本运行完成,您的桌面上将会打开一个浏览器并显示测试运行的结果。(参见图 17。)


图17.测试运行结果
Figure 17. New browser window that displays the results of the test run





回页首


获得更多的信息或者帮助

如果您想知道记录和回放一个脚本更详细的过程,请阅读Help > Cheat Sheets下面的Getting Started with Functional Tester Cheat Sheet。不要忘记:您可以经常在 developerWorks 的Functional and GUI Testing 论坛上获得帮助(也被列在 参考资料中)。



参考资料

学习

获得产品和技术

讨论


关于作者

Michael Kelly 目前是一位独立咨询师,并提供 IBM Rational 测试工具的自定制培训。他咨询、撰写和演讲过有关软件测试的主题。他目前就任印第安纳波利斯质量保证协会的程序主管,同时还是软件测试协会的一名主要主管。可以通过电子邮件 Mike@MichaelDKelly.com 与他取得联系。




对本文的评价










回页首


IBM 公司保留在 developerWorks 网站上发表的内容的著作权。未经IBM公司或原始作者的书面明确许可,请勿转载。如果您希望转载,请通过 提交转载请求表单 联系我们的编辑团队。
    关于 IBM 隐私条约 联系 IBM 使用条款