首页 > 解决方案 > 使用复选框 - 无法检查复选框是否被禁用

问题描述

寻找对此的一些评论,让我知道这是否是检查禁用复选框的正确方法。

我的页面模型的一部分在这里:

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

标签: testingautomationautomated-testse2e-testingtestcafe

解决方案


我想我发现了问题,我没有定义

const label = Selector('label');

推荐阅读