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

API Inconsistency: find! vs find_by! #20

Open
tf opened this issue Apr 21, 2015 · 5 comments
Open

API Inconsistency: find! vs find_by! #20

tf opened this issue Apr 21, 2015 · 5 comments

Comments

@tf
Copy link
Contributor

tf commented Apr 21, 2015

Hi,

I just noticed the addition of the find_by! method in #19. From my point of view, this introduces an unfortunate semantic inconsistency with the find! method added earlier in #14.

When using a JS Capybara driver:

  • find! waits for elements to appear
  • find_by! simply raises an exception if the element is not already on the page

As mentioned in #15, I am not sure how the waiting behavior could be added to find_by! in the presence of computed attributes. As a last resort one could consider renaming find! to something like await. Still this would require a breaking API change.

@tf tf changed the title API inconsistency: find! vs find_by! API Inconsistency: find! vs find_by! Apr 21, 2015
@ngauthier
Copy link
Owner

Hm, interesting point. The ! really just means "it will throw an exception" but I totally understand how Capybara wait behavior can be confusing. IMO the main workaround would be something like wrapping it in a timeout and sleeping and checking until Capybara.current_wait_time.

Although generally I like to follow the capybara pattern of:

  1. Check that we are on the page we expect to be
  2. Look for stuff

So that (1) makes sure we have page content and asserts the context of the test. That way I don't get confused about broken tests as often.

But yeah I agree that I'm not sure how to remedy this exactly!

@tf
Copy link
Contributor Author

tf commented Apr 21, 2015

Well yeah, but sometimes you already are on the correct page but still have to wait for stuff to appear (i.e. ajax).

@ngauthier
Copy link
Owner

Yup. Would be nice if find_by! was more capybara-like.

@tf
Copy link
Contributor Author

tf commented Apr 22, 2015

This also seems to be the way capybara implements waiting. Still, it somehow feels like re-implementing capybara features in domino.

@ngauthier
Copy link
Owner

Capybara used to expose a wait function but too many people used it so they
removed it 😄
On Apr 22, 2015 4:26 AM, "Tim Fischbach" [email protected] wrote:

This also seems to be the way capybara implements waiting
https://github.com/jnicklas/capybara/blob/ba5ba340e8847105312de16705a80dfb5ee92475/lib/capybara/node/base.rb#L76.
Still, it somehow feels like re-implementing capybara features in domino.


Reply to this email directly or view it on GitHub
#20 (comment).

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