51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 5713|回复: 8
打印 上一主题 下一主题

RFT如何测试RCP应用?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-11-20 16:23:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
RCP本质上是Eclipse的插件,所以当开发RCP应用程序时,可以利用Eclipse平台UI外观和框架来快速地进行开发。例如创建一个菜单栏、工具栏,在RCP开发中很容易,只需要作一定的配置后,编写简单的代码就可以实现复杂的功能,这样就避免了许多重复性的工作。

RCP的系统可以脱离Eclipse平台独立运行,这样大大减少了打包程序后文件的体积,使系统更加小巧和雅观。


但RFT录制的时候,不能识别对象。该如何解决??
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-11-24 02:50:14 | 只看该作者
我记得是在哪里设置一下,取消RFT对Eclispe的屏蔽。
究竟是哪里设置,或者是要修改哪个文件,我还真不记得了:(

等上班问问IBM的人。
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2007-11-24 05:02:03 | 只看该作者
/*
* (c) Copyright IBM Corp. 2000, 2006. All Rights Reserved.
* Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement.
*/
package superscript;

import testobject.eclipse.WorkbenchTestObject;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.AmbiguousRecognitionException;
import com.rational.test.ft.ObjectNotFoundException;
import com.rational.test.ft.RationalTestException;

/**
* This class provides some methods that may be useful when testing
* plugins running inside the eclipse shell (see http://www.eclipse.org/).
* Note that this code makes use of internal eclipse classes, and consequently
* may break with future versions of eclipse.
*
* This class illustrates invoking static methods in the SUT and using custom
* TestObjects.
* There is also sample code illustrating the use of find(), where a TestObject can be found
* based on a given set of properties.
*/
public abstract class EclipseScript extends SwtScript
{
        /**
         * Get a workbench object from any object from the workbench UI
         * Note that the returned TestObject is registered, and should be unregistered
         * by the caller.
         */
        public WorkbenchTestObject getWorkbench(TestObject object)
        {
                DomainTestObject domain = object.getDomain();
                if (domain == null)
                        throw new SwtScriptException("can't get domain from object: "+object.getClass().getName());

//                TestObject workspace = (TestObject)domain.invokeStaticMethod( "org.eclipse.ui.internal.WorkbenchPlugin", "getPluginWorkspace");
                TestObject workbenchPlugin = (TestObject)domain.invokeStaticMethod( "org.eclipse.ui.internal.WorkbenchPlugin", "getDefault");
                return new WorkbenchTestObject((TestObject)workbenchPlugin.getProperty("workbench"));
        }

        /**
         * General-purpose exception for eclipse scripts
         */
        public static class SwtScriptException extends RuntimeException
        {
                SwtScriptException(String s) { super(s); }
        }
       
        /**************************************************************************************
         * The following are methods used for interacting with the Workspace Launcher window,
         * which is not testable (using recording) by default.
         * Use of find() using TestObject properties is shown.
         * Note that this is a Windows only solution.
         **************************************************************************************/
       
        /**
         * Call this method to select a particular workspace from the Workspace
         * Launcher drop-down menu.
         * @param workspace The name of the workspace to connect to.
         *                                         It should be a choice available in the Launcher drop-down.
         * @return                        <code>true</code> if a workspace was selected.
         */
        public boolean selectWorkspace(String workspace)
        {
                boolean selected = false;
                TopLevelSubitemTestObject window = getWorkspaceWindow();
                if (window != null)
                {
                        try
                        {
                                TestObject[] found = window.find(atList(
                                        atDescendant(".class", "SWT_Window0"),
                                        atChild(".class", "ComboBox", ".text", "Workspace:")));
                                checkFindResults(found, "Workspace Selection ComboBox");
                                try
                                {
                                        ((TextSelectGuiSubitemTestObject)found[0]).click(ARROW);
                                        ((TextSelectGuiSubitemTestObject)found[0]).click(atText(workspace));
                                        selected = true;
                                }
                                finally
                                {
                                        found[0].unregister();
                                }
                        }
                        finally
                        {
                                window.unregister();
                        }
                }
                return selected;
        }
       
        /**
         * Call this method to click the "OK" button in the Workspace Launcher.
         * @return        <code>true</code> if the OK Button was clicked.
         */
        public boolean clickOK()
        {
                boolean clicked = false;
                TopLevelSubitemTestObject window = getWorkspaceWindow();
                if (window != null)
                {
                        try
                        {
                                TestObject[] found = window.find(
                                        atDescendant(".class", ".Pushbutton", ".name", "OK"));
                                checkFindResults(found, "OK Button");
                                try
                                {
                                        ((GuiTestObject)found[0]).click();
                                }
                                finally
                                {
                                        found[0].unregister();
                                }
                                clicked = true;
                        }
                        finally
                        {
                                window.unregister();
                        }
                }
                return clicked;
        }
       
        /**
         * Call this method to obtain a TestObject for the Workspace Launcher window.
         * Please refer to "clickOK" and "selectWorkspace" for the most common
         * functionality needed, pre-canned.
         * @return        a TopLevelSubitemTestObject representing the Workspace
         *                         Launcher window.
         *                        The TestObject must be unregistered.
         */
        public TopLevelSubitemTestObject getWorkspaceWindow()
        {
                TopLevelSubitemTestObject topWindow = null;
                RootTestObject rootTO = getRootTestObject();
                IWindow[] topWindows = rootTO.getTopWindows();
                for (int i=0; i<topWindows.length; ++i)
                {
                        String title = topWindows.getText();
                        if (title != null && title.equals("Workspace Launcher"))
                        {
                                Long hWnd = new Long(topWindows.getHandle());
                                // By specifying domain "Win" and giving a window handle,
                                // we will enable the window for testing.
                                TestObject[] found = rootTO.find(
                                        atChild(".domain", "Win", ".hwnd", hWnd));
                                checkFindResults(found, "Workspace Launcher window");                               
                                topWindow = (TopLevelSubitemTestObject)found[0];
                        }
                }
                if (topWindow == null)
                {
                        throw new ObjectNotFoundException("Unable to locate: Workspace Launcher window");
                }
                return topWindow;
        }
       
        // The name of the eclipse application, as defined in the Application Configuration tool.
        public String ECLIPSE_APP_NAME = "eclipse";   
        // The maximum amount of time to wait for an eclipse application to start.
        public double MAX_STARTUP_WAIT = 30.0;
        /**
         * Call this method to start an eclipse application, select the default workspace
         * (if applicable), and wait for the workspace to appear.
         * @return        <code>true</code> if the eclipse application starts and the workspace appears.
         */       
        public boolean startEclipse()
        {
                boolean started = false;
                startApp(ECLIPSE_APP_NAME);
                RootTestObject root = getRootTestObject();
                Timer timer = new Timer();
                boolean clickedOK = false;
                do
                {
                        TestObject[] found = root.find(
                                        atChild(".domain", "Java", "class", "org.eclipse.swt.widgets.Shell"));
                        if (found.length == 0)
                        {
                                try
                                {
                                        if (!clickedOK)
                                        {
                                                clickedOK = clickOK();
                                                if (clickedOK)
                                                {
                                                        sleep(.5);
                                                }
                                        }
                                }
                                catch (RationalTestException e)
                                {                                       
                                }
                        }
                        else
                        {
                                started = true;
                                unregister(found);
                        }
                        sleep(.5);
                } while (!started && !timer.isTimeUp(MAX_STARTUP_WAIT));
                return started;
        }               
       
        /**
         * Utility method to make sure we find one and only one TestObject for a given search.
         */
        private void checkFindResults(TestObject[] found, String objectDescription)
        {
                if (found.length == 0)
                {
                        throw new ObjectNotFoundException("Unable to locate: " + objectDescription);
                }
                else if (found.length > 1)
                {
                        unregister(found);
                        throw new AmbiguousRecognitionException("Found " + found.length + " matches for: " + objectDescription);
                }
        }       
}
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2007-11-24 05:02:52 | 只看该作者
是不是superhelper用这个就可以?
手册里面找到的。
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2007-11-26 14:42:12 | 只看该作者
看不懂。。
纪录器里有个排除选项
explorer,devenv
将devenv去掉了,还是不能识别。
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2007-12-13 17:54:14 | 只看该作者
For your convenience, the new message is included below:
--------------------------------------------------------------
This is the instruction I got from someone in IBM....

****************************************************************

if You could not enable the RCP application in RFT701 by just clicking on enable button in the Enable application for Testing Tab .  

  then do the following:
   - To configure the RCP  application: you copied the

   com.rational.test.ft.enabler.wsw_7.0.0.v200706080608 from  C:\Program
  Files\IBM\SDP70\FunctionalTester\EclipseEnabler of Eclipse701 and pasted
  it in the plugins folder of The RCP application.  

   - You created a features folder on the same level as plugins folder.


if the application is enabled in RFT but the objects are not recorded in  

  RFT. This means, if you click on any object during recording, nothing is
  written into the recording window.  
  then do the following:

  Go to the Configuration folder of the RCP application:  
  Edit config.ini file,
  Search line osgi.bundles= and add com.rational.test.ft.enabler.wsw in
  the beginning. The line should look like
  osgi.bundles=com.rational.test.ft.enabler.wsw,com.cif.front.common,...  

  At the end of the file you osgi.bundles.defaultStartLevel=4,
  Put please # in the beginning like this
  #osgi.bundles.defaultStartLevel=4 save the file  

  Go to  C:\Program Files\IBM\SDP70Shared\plugins,  copy
  org.eclipse.ui.workbench.compatibility_3.2.0.I20060605-1400 folder  and
  org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar file the
  past them in plugins of the RCP application  

  Restart your application and start the test again.
************************************************************
Hope this help.
回复 支持 反对

使用道具 举报

该用户从未签到

7#
 楼主| 发表于 2008-1-16 16:55:59 | 只看该作者
已解决,3ks!
回复 支持 反对

使用道具 举报

该用户从未签到

8#
发表于 2009-2-12 16:56:36 | 只看该作者
楼主能用中文说一下具体操作吗?
回复 支持 反对

使用道具 举报

该用户从未签到

9#
发表于 2009-8-6 14:30:38 | 只看该作者
简单点说,
1. 找到RFT安装目录(比如C:\Program Files\IBM\SDP70\FunctionalTester)下的EclipseEnabler
2. 将里面的features和plugins的内容直接拷贝至待测软件的相应目录下面
3. 再试下用RFT录制脚本
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-23 21:39 , Processed in 0.067835 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表