java - TestFX 中是否有测试选择框选择的功能?
问题描述
我想用 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 吗?
解决方案
我现在已经解决了如下问题:
verifyThat("#receiverChoiceBox", node -> this.userInformationMap.get(2).equals(((ChoiceBox)node).getValue()));
推荐阅读
- azure-cognitive-search - 在天蓝色搜索中索引字典属性
- python - 如何将文本分组在一行中并计算python pandas中的持续时间?
- java - Maven:从github下载源码,编译成jar,在WEB-INF/lib目录下包含jar
- django - 基于另一个字段的 Django ModelForm 字段查询集
- mysql - 防止两个外键同时为 NULL
- python - 有没有一种更简洁的方法可以在 Python 中编写这个布尔比较?
- mern - 部署到heroku时找不到.scss文件
- python - Google Places API - 按非标准类别/类型搜索
- javascript - 无法从我的 create-react-app 中的“redux-saga”导入 createSagaMiddleware
- php - 使用 python 将数组打包为 16 位字符串