我想用FEST來測試一個Swing組件是不可見的。使用org.fest.swing.fixture.FrameFixture :: panel()發送Swing面板,它需要面板顯示?
我嘗試使用org.fest.swing.fixture.FrameFixture
方法panel(「foo」)
但由於它需要requireShowing=true.
什麼用FEST慣用的方法來找到一個面板irregardless如果它現在是可見的失敗?
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類似的測試,使用 周杰倫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]
您是否將面板添加到框架中?並稱setVisible(false)? – keuleJ 2015-05-19 05:42:55
@keuleJ對兩者都是。用更多信息更新了問題。 – k1eran 2015-05-19 09:36:46
而你做panel.setName(「foo」)?你嘗試過使用調試器嗎? – keuleJ 2015-05-19 11:54:03