要素の指定された属性が存在するかどうか、およびオプションで期待される値を持っているかどうかを確認します。

使用方法

                    browser.expect.element(selector).to.have.attribute(attribute)
                

this.demoTest = function (browser) {
  browser.expect.element('body').to.have.attribute('data-attr');
  browser.expect.element('body').to.not.have.attribute('data-attr');
  browser.expect.element('body').to.not.have.attribute('data-attr', 'Testing if body does not have data-attr');
  browser.expect.element('body').to.have.attribute('data-attr').before(100);
  browser.expect.element('body').to.have.attribute('data-attr')
    .equals('some attribute');
  browser.expect.element('body').to.have.attribute('data-attr')
    .not.equals('other attribute');
  browser.expect.element('body').to.have.attribute('data-attr')
    .which.contains('something');
  browser.expect.element('body').to.have.attribute('data-attr')
    .which.matches(/^something\ else/);
};

パラメータ

名前 説明
attribute 文字列

属性名

message
オプション
文字列

出力に表示するオプションのログメッセージ。省略した場合は、デフォルトのメッセージが表示されます。