正在对此进行一些检查,以使我知道这是否是检查禁用复选框的正确方法。
这里是我的页面模型的一部分:
class eligibleAccountType {
constructor (text) {
this.label = label.withText(text);
this.checkbox = this.label.find('input[type=checkbox]');
}
}
class ProgramOptionsSubscriptionRulesPage{
constructor(){
this.contractsatAccountLevel = Selector("#program_option_allow_participant_account_contracts")
this.eligibleAccountTypesList = [
new eligibleAccountType("Residential"),
new eligibleAccountType("Commercial"),
new eligibleAccountType("Industrial")
];
我的部分测试在这里
if (userdata.userrole == "Read Only") {
for (const eligibleAccountType of programOptionsSubscriptionRulesPage.eligibleAccountTypeList) {
await t.expect(eligibleAccountType.hasAttribute('disabled')).ok()
}
}
出现错误,例如:
ReferenceError: label is not defined
我在您的示例中看不到label
定义。您可以尝试使用eligibleAccountType
重写Selector
构造函数:
class eligibleAccountType {
constructor (text) {
this.label = Selector(...).withText(text);
this.checkbox = Selector(...).find('input[type=checkbox]');
}
}
在这种情况下,检查必需元素的标记可能很有用。请参考“ TestCafe示例”存储库:https://github.com/DevExpress/testcafe-examples/blob/master/examples/element-properties/check-element-markup.js