I want to use FEST to test that a Swing component is invisible.
I try to use org.fest.swing.fixture.FrameFixture
method panel(“foo”)
but that fails since it requires requireShowing=true.
What is idiomatic approach using FEST to find a panel irregardless if it's visible right now?
Assert.assertFalse(panel.getFooPanel().isVisible()); // works ok
myFrameFixture.panel(“foo”).requireNotVisible(); // fails
The second line gives this...
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].
EDIT :
I tied a similar test with a JComboBox, using the pattern suggested by
Jay Fichadia, but it still seems to require the item to be visible before I invoke .requireNotVisible()
e.g. trying new JComboBoxFixture(frame.robot,"grid_combo");
alone (without the actual requireNotVisible() check) gives ...
Caused an ERROR
Unable to find component using matcher org.fest.swing.core.NameMatcher[name='grid_combo', type=javax.swing.JComboBox, requireShowing=true].
despite the fact we have in the Component hierarchy:
javax.swing.JComboBox[name='grid_combo', selectedItem='A', contents=['A', 'B'], editable=false, enabled=false, visible=false, showing=false]
I just encountered same problem and after seeing no answer here, I found a solution myself.
The problem is that frameFixture by default look only for components that are visible. So if you want to search for not visible components, you have to change this setting. You can do this by using:
myFrameFixture.robot.settings().componentLookupScope(ComponentLookupScope.ALL);