Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way of checking meta info of page object #483

Open
yratanov opened this issue Feb 28, 2020 · 1 comment
Open

Provide a way of checking meta info of page object #483

yratanov opened this issue Feb 28, 2020 · 1 comment

Comments

@yratanov
Copy link
Contributor

While working on assert lib for page object I faced and issue described here.

There is no way to check if property is a property or a function without calling it, for example:

create({
  clickOnMe: clickable('a'),
  href: attribute('href', a),
});

So to check if property is a function I need to call it like this:

typeof page.clickOnMe === 'function' // true
typeof page.href=== 'function' // false

The problem with this is that we actually execute getter and if it raises an error, our check will fail.

typeof page.href === 'function' // Element not found!

Do you think it's possible to store it somehow?

@ro0gr
Copy link
Collaborator

ro0gr commented Mar 2, 2020

Yes, there is such a limitation currently. I believe a good way to do it would be go play around getPageObjectDefinition(. But:

  • that's private for now
  • even with that you don't have a way to distinct between props VS actions.

As a short term solution, we could mark all the current built-in action descriptors by smth like isAction: true. But that doesn't feel super optimal to me, cause on the assertions end you would need to use private getPageObjectDefinition( and private isAction, which can easily breake because of hard dependencies on private APIs.

I think we should solve it, when introducing a public way to declare a custom action. I expect it to be done in v2.

Meanwhile, I think your current approach to create assertions for actions is a good(in terms of reliability) solution for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants