The application has checkboxes text depending on the the selection of ComboBox in previous Step. I need to select one of the checkboxes in the JPanel using text. Is there a way to do it in AssertJ Swing
Asked
Active
Viewed 127 times
1 Answers
0
If you can modify the code that creates the checkboxes then give them distinct names:
JCheckBox cb1 = new JCheckBox();
cb1.setName("CheckBox1");
JCheckBox cb2 = new JCheckBox();
cb2.setName("CheckBox2");
The name of a checkbox (of any component) is not displayed, but can be helpful while debugging the code and while testing the code.
To select the checkboxes with AssertJ Swing, you can then use the following code (with frame
referencing the FrameFixture
):
frame.checkbox("CheckBox1").check();
frame.checkbox("CheckBox2").check();

Thomas Kläger
- 17,754
- 3
- 23
- 34