繁体   English   中英

将FEST-Swing与Java小程序一起使用

[英]Using FEST-Swing with a Java applet

我发现FEST-Swing能够自动执行Java小程序上的UI操作。

FEST-Swing还可以测试桌面应用程序和小程序(在查看器和浏览器中)。

我试图准备一个脚本来查看其功能,但无法弄清楚如何将小程序源加载到FEST来执行操作。

如何将Java Applet加载到FEST中? 具体来说,我想举一个关于如何将下面的applet加载到FEST中的示例。 http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html

我在脚本中想要的只是单击“下一步”和“上一步”按钮。

如何加载一个AppletFramFixture描述这里 为了使此运行,您需要将Next-Button的类型从Button更改为JButton因为FEST仅在SWING组件上起作用,而在AWT组件上不起作用。 另外,您还必须设置按钮的名称,以便FEST可以标识测试用例中的按钮。 为此,请添加以下行:

JButton nextButton = new JButton("next");//sets the visible Label
nextButton.setName("nextButton");//sets a name invisible for the User.

现在,您可以在测试用例中找到您的Button。 我使用了这个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();
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM