[英]Using FEST-Swing with a Java applet
I found that FEST-Swing has the capability to automate UI actions on Java applets. 我发现FEST-Swing能够自动执行Java小程序上的UI操作。
FEST-Swing can also test desktop applications as well as applets (in a viewer and in-browser.) FEST-Swing还可以测试桌面应用程序和小程序(在查看器和浏览器中)。
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. 我试图准备一个脚本来查看其功能,但无法弄清楚如何将小程序源加载到FEST来执行操作。
How can I load a Java Applet into FEST? 如何将Java Applet加载到FEST中? Specifically, I would like an example on how to load the below applet in to FEST. 具体来说,我想举一个关于如何将下面的applet加载到FEST中的示例。 http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html 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. 我在脚本中想要的只是单击“下一步”和“上一步”按钮。
how to load an Applet
to a FramFixture
is described here . 如何加载一个Applet
到FramFixture
描述这里 。 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. 为了使此运行,您需要将Next-Button的类型从Button
更改为JButton
因为FEST仅在SWING组件上起作用,而在AWT组件上不起作用。 Additional you have to set the Name of the Button, so that FEST can identity the button in the testcase. 另外,您还必须设置按钮的名称,以便FEST可以标识测试用例中的按钮。 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. 现在,您可以在测试用例中找到您的Button。 I used this TestCase and it worked well: 我使用了这个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.