Attribute
Methods
attribute
addon/-private/properties/attribute.js:70-90
Parameters
- attributeNamestring Name of the attribute to get
- selectorstring CSS selector of the element to check
- optionsObject Additional options- options.scopestring Nests provided scope within parent’s scope
- options.resetScopeboolean Override parent’s scope
- options.atnumber Reduce the set of matched elements to the one at the specified index
- options.multipleboolean If set, the function will return an array of values
- options.testContainerstring Context where to search elements in the DOM
 
- userOptions(optional, default- {})
Examples
// <input placeholder="a value">
const page = PageObject.create({
  inputPlaceholder: PageObject.attribute('placeholder', 'input')
});
assert.equal(page.inputPlaceholder, 'a value');
// <input placeholder="a value">
// <input placeholder="other value">
const page = PageObject.create({
  inputPlaceholders: PageObject.attribute('placeholder', ':input', { multiple: true })
});
assert.deepEqual(page.inputPlaceholders, ['a value', 'other value']);
// <div><input></div>
// <div class="scope"><input placeholder="a value"></div>
// <div><input></div>
const page = PageObject.create({
  inputPlaceholder: PageObject.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>
const page = PageObject.create({
  scope: 'scope',
  inputPlaceholder: PageObject.attribute('placeholder', ':input')
});
assert.equal(page.inputPlaceholder, 'a value');
Returns Descriptor