这里的问题是我有过滤器菜单,当我在UI中运行测试时,我必须选择一个带有复选框的标签,这表明该复选框正在检查中,但在复选框验证失败并抛出了服务员异常。 “ Wait.until(isChecked());”在此刻。
/ *我的测试用例* /
public void testCustomFieldBooleanVerification() {
NamedAccountsSection tab = NamedAccountSection;
tab.filterToggle.toggleOn();
tab.openFilterMenu().openAddFilterMenu().addFilter("ABM CUST BOOL3");
tab.openFilterMenu().closeAddFilterMenu();
tab.openFilterMenu().apply();
/* addFilter */
public AddFilterMenu addFilter(String filter) {
logger.debug("Adding filter:" + filter);
MktCheckBox checkbox = new MktCheckBox(new MktLabel(filter, locator).getLabeledInputLocator());
if (Check.that(checkbox.isCheckable())) {
checkbox.check();
}
return this;
}
/* CheckBox*/
public MktCheckBox(By locator, String description) {
super(locator, description);
}
/* check box condition*/
public MktCheckBox check() throws TimeoutException {
if (!Check.that(isUnchecked()) || !Check.that(isEnabled())) {
logger.warn(String.format("%s is already checked", description));
} else {
Wait.until(isCheckable());
logger.debug(String.format("Clicking on %s", description));
click();
Wait.until(isChecked());
}
return this;
}
public Waiter<Boolean> isChecked() {
return new Waiter<>(Connection.getWebDriver(), (ExpectedCondition<Boolean>) webDriver -> GuiObjectControl.isSelected(webElement));
}
/* Label Locator*/
public class MktLabel extends MktText {
static final String LABELED_IDENTIFIER = "//*[@id=(//label[text()='%s']/@for)]";
static final String LABEL_IDENTIFIER = "//label[text()='%s']";
protected String label;
public By getLabeledInputLocator() {
if(label == null) {
label = this.getText();
}
return By.xpath(String.format(LABELED_IDENTIFIER, label));
}