将 FEST-Swing 与 Java 小程序结合使用

发布于 2024-12-10 16:13:19 字数 592 浏览 1 评论 0原文

我发现 FEST-Swing 具有以下功能自动化 Java 小程序上的 UI 操作。

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

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

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

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

I found that FEST-Swing has the capability to automate UI actions on Java applets.

FEST-Swing can also test desktop applications as well as applets (in a
viewer and in-browser.)

I tried to prepare a script to see its capabilities, but I could not figure out how to load an applet source to FEST to take actions.

How can I load a Java Applet into FEST? Specifically, I would like an example on how to load the below applet in to FEST.
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html

All I want in the script is to click on Next and Previous buttons.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔少女心 2024-12-17 16:13:19

这里。要使其运行,您需要将 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.

现在您可以在测试用例中找到您的按钮。我使用了这个测试用例,效果很好:

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();
    }
}

how to load an Applet to a FramFixture is described here. To get this running you need to change the type of the Next-Button from Button to JButton because FEST works only on SWING Components and not on AWT Components. Additional you have to set the Name of the Button, so that FEST can identity the button in the testcase. To do this, add this line:

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

now you can find your Button in the testcase. I used this TestCase and it worked well:

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();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文