faltest icon indicating copy to clipboard operation
faltest copied to clipboard

Extend capability of Element

Open MichalBryxi opened this issue 4 years ago • 1 comments

I tried to define custom element that inherits faltest Element:

const { Element: _Element } = require('@faltest/page-objects');

class Element extends _Element {
  async foo() {
    await super.click();
    await ...;
  }
}

And then I tried to use it in my code:

...
  button: create(
    '[data-test-my-button]',
  ),
...
  click: async() => {
    await pageObject.button.foo();
  }
...

But this ends with:

TypeError: pageObject.button.foo is not a function

MichalBryxi avatar Mar 03 '21 17:03 MichalBryxi

Notes for my future self:

maybe it could via the prototype chain of the class container? or you could set it in the constructor?

MichalBryxi avatar Mar 04 '21 13:03 MichalBryxi