[英]Using WindowFinder to find a modal dialog
I am using FEST to test my Java dialogs and I need to test that a new modal dialog is created. 我正在使用FEST测试我的Java对话框,我需要测试是否创建了一个新的模式对话框。
@Before
public void setUp() throws Exception {
TestFrame testFrame = GuiActionRunner.execute(new GuiQuery<TestFrame>() {
@Override
protected TestFrame executeInEDT() throws Throwable {
panel = new CustomPanel();
return new TestFrame(panel);
}
});
frameFixture = new FrameFixture(testFrame);
frameFixture.show();
frameFixture.robot.waitForIdle();
}
Note: TestFrame is a helper class which extends JFrame for use in unit testing. 注意:TestFrame是一个辅助类,它扩展了JFrame以用于单元测试。
In my test, I click a button which makes a modal dialog appear. 在我的测试中,我单击一个按钮,显示模式对话框。 I am trying to find and verify the dialog is created, however all of my attempts aren't able to find anything: 我试图找到并验证对话框是否已创建,但是我的所有尝试都无法找到任何内容:
WindowFinder.findDialog("Window Title")).using(robot);
Where robot = 机器人=
I have also tried specifying the lookup scope of the robot: 我也尝试过指定机器人的查找范围:
robot.settings().componentLookupScope(ComponentLookupScope.ALL);
There are lots of FEST examples online which make a call to robot()
but I can't find out how or what this robot function is supposed to be. 在线有很多FEST例子可以调用robot()
但我无法知道这个机器人函数应该是什么或者是什么。
Why am I unable to find my newly created popup dialog? 为什么我找不到新创建的弹出对话框?
Try adding a lookup time: 尝试添加查找时间:
WindowFinder.findDialog(MyDialog.class).withTimeout(10000).using(robot);
For more info: http://fest.googlecode.com/svn-history/r458/trunk/fest/fest-swing/javadocs/org/fest/swing/fixture/util/WindowFinder.html 欲了解更多信息: http : //fest.googlecode.com/svn-history/r458/trunk/fest/fest-swing/javadocs/org/fest/swing/fixture/util/WindowFinder.html
Recently, I am also using FEST to do the testing. 最近,我也在使用FEST进行测试。
When working on the same situation I use the following method to simulate the "get this window/dialog" action 在处理相同的情况时,我使用以下方法来模拟“获取此窗口/对话框”操作
private DialogFixture blablawindow;
...
blablawindow = WindowFinder.findDialog("XXX").using(robot());
blablawindow.button("button1").click();
As I am new to FEST, so for me, something need to be careful: 因为我是FEST的新手,所以对我来说,需要注意一些事情:
XXX is not the actual text that is shown on UI, you need to check the source code to see the name of the window/dialog: looks like this setName("actual name of window");
XXX不是UI上显示的实际文本,您需要检查源代码以查看窗口/对话框的名称:看起来像这个setName("actual name of window");
or any swing element private javax.swing.JButton button1;
或任何swing元素private javax.swing.JButton button1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.