Search code examples
testingautomationautomated-testse2e-testingtestcafe

Working with checkboxes - unable to check if checkboxes are disabled


Looking for some review on this to let me know if this is the right approach to check for disabled checkboxes.

Part of my page model here:

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")
      ];

Part of my test here

if (userdata.userrole == "Read Only") {
 
 for (const eligibleAccountType of programOptionsSubscriptionRulesPage.eligibleAccountTypeList) {
            await t.expect(eligibleAccountType.hasAttribute('disabled')).ok()
          }
        }

Getting error such as:

ReferenceError: label is not defined

Solution

  • I think I found out the problem, I had not defined the

    const label = Selector('label');