expect.element().attribute Suggest edits
Since: v0.7Checks if a given attribute of an element exists and optionally if it has the expected value.
Usage
browser.expect.element(selector).to.have.attribute(attribute)
Example
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/);
};
Parameters
Name | Type | description |
---|---|---|
attribute |
string | The attribute name |
message Optional |
string | Optional log message to display in the output. If missing, one is displayed by default. |