TestProject Forum
Powered by leading experts in the test automation community

Assert checkbox is not checked with nightwatch.js

I tried using attributeEquals() to check if checkbox is enabled but I receive error that ‘checked’ attribute doesn’t exist

browser
...
...
.verify.attributeEquals('#myCheckbox', 'checked', 'false')
.end();

Is there another method to Assert this functionality ?

Try running this

module.exports = {
  tags: ['checkbox'],

  'select checkbox' : function (browser) {
    browser
      .url('http://sample.com')
      .verify.visible('input[id="checkboxId"]', 'Checkbox visible')
      .click('input[id="checkboxId"]')
      .element('id', 'checkboxId', function(response) {
        client.assert.ok(response.value.ELEMENT, 'Checkbox response OK');
        client.elementIdSelected(response.value.ELEMENT, function(result){
          client.verify.ok(result.value, 'Checkbox selected');
        });
      })
      .end();
  }
};