我发现节庆秋千具有在Java上自动化UI操作的能力。
FEST-Swing还可以测试桌面应用程序和applet(在查看器和浏览器中)。
我试着准备一个脚本来查看它的功能,但是我想不出如何加载applet源代码来执行操作。
如何将Java小程序加载到FEST中?具体来说,我想要一个关于如何加载下面的applet到FEST的例子。http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html
我只想在脚本中单击Next和以前的按钮。
发布于 2012-08-28 21:03:14
介绍了如何将Applet加载到FramFixture中,并介绍了这里。要运行该程序,您需要将Next-Button的类型从Button更改为JButton,因为FEST只在SWING组件上工作,而对AWT组件不起作用。另外,您必须设置Button的名称,以便FEST可以在testcase中标识按钮。要做到这一点,添加以下一行:
JButton nextButton = new JButton("next");//sets the visible Label
nextButton.setName("nextButton");//sets a name invisible for the User.现在你可以在测试箱中找到你的按钮了。我使用了这个TestCase,它运行得很好:
public class FestTestApplet extends TestCase{
private AppletViewer viewer;
private FrameFixture applet;
@Override
public void setUp() {
final Applet app = new GraphicsTest();
viewer = AppletLauncher.applet(app).start();
applet = new FrameFixture(viewer);
applet.show();
}
public void testNextButtonClick() {
applet.button("nextButton").click();//finds the button by the name
applet.robot.waitForIdle();//give the GUI time to update
//start your asserts
}
@Override
public void tearDown() {
viewer.unloadApplet();
applet.cleanUp();
}
}https://stackoverflow.com/questions/7806601
复制相似问题