element.js 612 B

123456789101112131415161718192021222324
  1. /**
  2. * Class that all elements subclass from
  3. *
  4. * @param {Object} options Element options defined in page object
  5. * @constructor
  6. */
  7. function Element(options) {
  8. this.parent = options.parent;
  9. if (!options.selector) {
  10. throw new Error('No selector property for element "' + options.name +
  11. '" Instead found properties: ' + Object.keys(options));
  12. }
  13. this.name = options.name;
  14. this.selector = options.selector;
  15. this.locateStrategy = options.locateStrategy || 'css selector';
  16. }
  17. Element.prototype.toString = function() {
  18. return 'Element[name=@' + this.name + ']';
  19. };
  20. module.exports = Element;