檢查元素的給定 DOM 屬性是否具有預期的值。如需所有可用的 DOM 元素屬性,請參閱 MDN 的元素文件

用法

範例

this.demoTest = function (browser) {
  browser.expect.element('body').to.have.property('className').equals('test-class');
  browser.expect.element('body').to.have.property('className').matches(/^something\ else/);
  browser.expect.element('body').to.not.have.property('classList').equals('test-class');
  browser.expect.element('body').to.have.property('classList').deep.equal(['class-one', 'class-two']);
  browser.expect.element('body').to.have.property('classList').contain('class-two');
  browser.expect.element('body').to.have.domProperty('classList').contain('class-two');
};

參數

名稱 類型 描述
property 字串

屬性名稱

message
選填
字串

在輸出中顯示的選填記錄訊息。如果遺失,則會預設顯示一個。