-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Option matches should be strict #681
Comments
It's because when you're trying to find |
I see, thanks. I was looking at the comments for So, the default behavior is to match anything that contains the value (and not just starts with it, i.e. This doesn't seem obvious or intuitive (and perhaps that's just my xpath ignorance). But certainly a better error message can be shown when multiple matches are found. The error But thanks again. |
Are you using Capybara master? I would recommend sticking with the latest gem release unless you're well informed about the changes that have happened since. master is not compatible with the 1.x branch. |
Yes, I am. My main issue was with regards to the error messaging, which #682 may address. Regardless, I think that it makes more sense for |
Now that capybara validates that just one element matches your criteria, shouldn't be good to have a default configuration where you can choose if you want an exact or a partial match for the elements?
And also should have a way to override the default match type during execution if you want:
|
+1 on @greis's suggestion. |
I don't like the idea of an option to specify whether the match should be exact or not. On the other hand, it seems that with the current behaviour, we should probably switch to matching exactly. |
I'm having a similar issue after upgrading from Capybara 1. click_link "Hello" gives error. It used to find "Hello", but now it finds 2 elements since I also have a "Hello world" link. @jnicklas writes that Capybara should probably switch to matching exactly. I assume this has not been done? Or is there a setting that I can use? Selecting the first link is not appropriate as I want the exact match and the exact match might not be the first link. |
Unfortunately, there is no such option yet. |
@jnicklas Do you think it will be good to have all |
Yes, but I'd rather solve this problem properly rather than breaking compatibility unnecessarily without arriving at a really good solution. I have some ideas, which I'll present to the mailing list at some point soon. |
I'm also experiencing this issue:
|
Thank you. Very helpful. -Kelly On Thu, Feb 14, 2013 at 1:25 PM, Andrey Botalov notifications@github.comwrote:
Kelly Felkins |
I had trouble figuring out how to best test this outside of Rails, but this is my issue in a Rails 3.2.3, Rspec, Capybara (rack-test), Turnip setup.
If I have the following HTML:
This step:
works as expected when
n >= 10
and fails whenn < 10
with the error:If I replace the step with:
It spits out a bunch of
true
s (as I would expect).If I have the following HTML:
Then the step works as expected with (
n
any of the characters).If I have the following HTML:
Then the step works as expected (with
n
the result of adate.strftime('%d')
).If someone could point my in a better direction with regards to testing outside of Rails, I'll see if I can better locate the issue behind my problem.
The text was updated successfully, but these errors were encountered: