Search code examples
javaswingassertj

JInternalFrameFixture.comboBox() in AssertJ Swing 3.2


I'm migrating some code from FEST Swing 1.2.1 to AssertJ Swing 3.2. In the old code there are calls to

  • JInternalFrameFixture.comboBox()
  • JInternalFrameFixture.label()
  • JInternalFrameFixture.slider()

Unfortunately I do not see any matching method in JInternalFrameFixture of AssertJ Swing. What should I use instead of the methods above in AssertJ Swing 3.2?

I've found that ComponentContainerFixture has a comboBox() method but JInternalFrameFixture does not implement this one in AssertJ Swing.


Solution

  • In AssertJ 3.2, given access to AssertJ's Robot, and an already existing JInternalFrameFixture, you can find a combo box within an internal frame with the following snippet:

    robot().finder().findByType(internalFrameFixture.target(), JComboBox.class);
    

    Additonally, I have submitted a pull request to assertj-swing to allow the fluent style that you are describing, i.e., frame.internalFrame().comboBox(). Hopefully it will be incorporated into a future version of AssertJ Swing.