Attribute
Methods
Table of Contents
attribute
Parameters
attributeNamestring Name of the attribute to getselectorstring CSS selector of the element to checkuserOptions(optional, default{})-
optionsObject Additional options
Examples
// <input placeholder="a value">
import { create, attribute } from 'ember-cli-page-object';
const page = create({
inputPlaceholder: attribute('placeholder', 'input')
});
assert.equal(page.inputPlaceholder, 'a value');
// <div><input></div>
// <div class="scope"><input placeholder="a value"></div>
// <div><input></div>
import { create, attribute } from 'ember-cli-page-object';
const page = create({
inputPlaceholder: attribute('placeholder', ':input', { scope: '.scope' })
});
assert.equal(page.inputPlaceholder, 'a value');
// <div><input></div>
// <div class="scope"><input placeholder="a value"></div>
// <div><input></div>
import { create, attribute } from 'ember-cli-page-object';
const page = create({
scope: 'scope',
inputPlaceholder: attribute('placeholder', ':input')
});
assert.equal(page.inputPlaceholder, 'a value');
- Throws any Will throw an error if no element matches selector
- Throws any Will throw an error if multiple elements are matched by selector
Returns Descriptor
attr
Get Element attribute value
For backward compatibility reasons we aim to follow the way the $.attr( works
Parameters
| Returns any string | undefined |