-
Notifications
You must be signed in to change notification settings - Fork 91
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
isVisible fails when element is not present #95
Comments
Hi @richmolj, thanks for taking the time to open the issue. When we first developed the addon, we thought it was a good idea to throw an Re-reading the documentation I couldn't find a reference to what you point out:
and from the website http://ember-cli-page-object.js.org/api/predicates/#isvisible
It doesn't say that it returns false otherwise, in fact it returns false only if the Please, let me know if there is another place in the documentation where the So, I think this brings up two different issues:
Again, thanks for opening the issue and let me know your thoughts |
Thanks for the in-depth reply @san650! To me
It's implied "else it returns false". I can see that's maybe my misunderstanding though. I'd be happy to improve the docs but IMHO it's not the desired behavior. I like the idea of refactoring a handlebars It is fair to say this could lead to false positives...a selector was changed and the logic is broken, but the test still passes since the old selector does not exist. I think this is really the cost of doing business any time you have an |
Ran into this problem to. I believe that there should be Currently, how do I assert that a component does not exist on the page? |
Okay, this worked (Mocha/Chai): expect(() => foo().isVisible()).to.throw('Element .foo not found.'); But it's clumsy. I want to do this instead: expect(foo().exists()).is.false; |
Been using asserting a 'count' of 0 for that purpose myself. |
The |
Right now you can test if a component is hidden on the page using the Also, note that every component already includes the
We're discussing changes like this one for the 1.0 release we're working on. The idea is to improve the API by adding, removing and changing methods based on this kind of feedback from the community. Please take a look at this PR which has a list of changes to be done. I prefer to improve the current properties instead of adding new ones when possible, we could have an option for var page = PageObject.create({
isVisible: isVisible('.a-class', { raise: false })
}); Additionally we could have a global configuration to make that option the default behavior, avoiding the need of using that flag every time you use the property. What do you think? Personally, I prefer to have the properties to raise an exception when you try to access them, I think it's easier to know what happened, although I agree that the current error message is a bit cryptic. Speaking of which, we have an idea of improving a lot the error messages, one of the reasons we had to start rewriting the internals for the 1.0. Please take a look at Better error messages. |
I agree with improving properties instead of adding new ones 👍. That said, I'd still think this is incorrect behavior. I expect To be clear, I also prefer properties raise when you try to access them and they are not present. And I actually don't have much of an issue with the error messages themselves - makes total sense when you're trying to tell it to click a button that isn't there. My issue is specific to only |
@richmolj you're right, let's change the behavior so We can add a Thanks everyone for the insights and feedback, it's really useful to improve the API. |
Fixed in master |
According to the documentation,
isVisible
should returnfalse
when the element is hidden OR the element does not exist. But the library currently throws an error when the element does not exist. I believe this is because the code ends up hittingfindWithAssert
: https://github.com/san650/ember-cli-page-object/blob/master/test-support/page-object/properties/is-visible.js#L16.The text was updated successfully, but these errors were encountered: