等上班问问IBM的人。作者: lovetest6 时间: 2007-11-24 05:02
/*
* (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;
/**
* 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());
/**
* 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);
}
}
}作者: lovetest6 时间: 2007-11-24 05:02
是不是superhelper用这个就可以?
手册里面找到的。作者: tthhbbandy 时间: 2007-11-26 14:42
看不懂。。
纪录器里有个排除选项
explorer,devenv
将devenv去掉了,还是不能识别。作者: lovetest6 时间: 2007-12-13 17:54
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.作者: tthhbbandy 时间: 2008-1-16 16:55
已解决,3ks!作者: wanghua0399 时间: 2009-2-12 16:56
楼主能用中文说一下具体操作吗?作者: garyliu 时间: 2009-8-6 14:30
简单点说,
1. 找到RFT安装目录(比如C:\Program Files\IBM\SDP70\FunctionalTester)下的EclipseEnabler
2. 将里面的features和plugins的内容直接拷贝至待测软件的相应目录下面
3. 再试下用RFT录制脚本