我想用 TestFX 测试我编写的 JavaFX GUI。在一个步骤中,我想测试一些选择框。
到目前为止,我已经尝试了以下代码:
this.step("fill creation view", () -> {
this.clickOn("#receiverChoiceBox").clickOn("Max Mustermann");
verifyThat("#receiverChoiceBox",
ComboBoxMatchers.hasSelectedItem(this.userInformationMap.get(2)));
});
但是,这将导致以下错误消息:
java.lang.AssertionError:
Expected: ComboBox has selection "xxx.model.dto.UserInformationDto@d84f7f5d"
but: was a xxx.gui.control.xxxChoiceBox (<xxxChoiceBox[id=receiverChoiceBox, styleClass=choice-box]>)
Expected :ComboBox has selection "xxx.model.dto.UserInformationDto@d84f7f5d"
Actual :a xxx.gui.control.xxxChoiceBox (<xxxChoiceBox[id=receiverChoiceBox, styleClass=choice-box]>)
我知道我正在使用 ComboBox Matcher,但我之前尝试过其他选项,但也没有用。ChoiceBox 有类似的 Matcher 吗?