用org.fest.Swing.ffixture.FrameFixture::panel()打开Swing面板,需要显示



我想使用FEST来测试Swing组件是否不可见。

我尝试使用org.fest.swing.fixture.FrameFixture方法panel(“foo”),但失败了,因为它需要requireShowing=true.

如果面板现在可见,那么使用FEST查找面板的惯用方法是什么?

Assert.assertFalse(panel.getFooPanel().isVisible()); // works ok
myFrameFixture.panel(“foo”).requireNotVisible(); // fails 

第二行给出了。。。

     javax.swing.JPanel[name='foo']
org.fest.swing.exception.ComponentLookupException: Unable to find component
using matcher 
org.fest.swing.core.NameMatcher[name='foo, type=javax.swing.JPanel, requireShowing=true].

编辑:

我将类似的测试与JComboBox捆绑在一起,使用Jay Fichadia,但在我调用.requireNotVisible()之前,似乎仍然需要该项可见例如,单独尝试new JComboBoxFixture(frame.robot,"grid_combo");(没有实际的requireNotVisible()检查)会给出。。。

    Caused an ERROR
Unable to find component using matcher org.fest.swing.core.NameMatcher[name='grid_combo', type=javax.swing.JComboBox, requireShowing=true].

尽管我们在组件层次结构中有这样一个事实:

javax.swing.JComboBox[name='grid_combo', selectedItem='A', contents=['A', 'B'], editable=false, enabled=false, visible=false, showing=false]

我刚刚遇到了同样的问题,在这里看不到答案后,我自己找到了解决方案。

问题是frameFixture默认情况下只查找可见的零部件。因此,如果您想搜索不可见的组件,则必须更改此设置。您可以使用:

myFrameFixture.robot.settings().componentLookupScope(ComponentLookupScope.ALL);

您是否尝试使用new JPanelFixture(robot,"foo").requireNotVisible()

最新更新