我试图让 Java FEST 找到一个弹出对话框,然后单击“是”按钮。 我有以下代码:
JOptionPaneFixture fixture = JOptionPaneFinder.findOptionPane().using(TestSite.myRobot);
fixture.buttonWithText("Yes" ).click();
在第一行抛出以下异常:
org.fest.swing.exception.WaitTimedOutError:等待使用匹配器 org.fest.swing.core.TypeMatcher[type=javax.swing.JOptionPane, requireShowing=true] 找到组件超时 无法使用匹配器 org.fest.swing.core.TypeMatcher[type=javax.swing.JOptionPane, requireShowing=true] 找到组件。
选项窗格当然会在我的 GUI 上弹出,但 FEST 找不到它。
我尝试使用此处提到的窗口查找器: FEST 单击时摇摆新框架,无法制作新框架固定装置
但是没有效果!!
请帮忙!
您必须识别要查找的元素的类型。 例如,我使用 JOptionPane.showMessageDialog() 并创建 javax.swing.JOptionPane 的对象 但是,默认情况下 JOptionPaneFinder.findOptionPane() 找不到 javax.swing.JOptionPane。
要修复,您必须使用这个:
JOptionPane t = (JOptionPane) managerFixture.robot.finder().find(c -> c instanceof JOptionPane);