I am trying to use Cucumber to check a filter feature on a web page. If I check specific movie ratings, then it should only show those movies with those ratings in the table. Here is my scenario:
When I check the following ratings: 'PG', 'R'
And I press Refresh
Then I should not see /PG/
And here is my step definition:
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
regexp = Regexp.new(regexp)
if page.respond_to? :should
page.should have_no_xpath('//*', :text => regexp)
else
assert page.has_no_xpath?('//*', :text => regexp)
end
end
But I am getting an "Ambiguous match" error.
Here is some of the HTML in case it's important:
<table id='movies'>
<thead>
<tr>
<th>Movie Title</th>
<th>Rating</th>
<th>Release Date</th>
<th>More Info</th>
</tr>
</thead>
<tbody>
<tr>
<td>Aladdin</td>
<td>G</td>
<td>1992-11-25 00:00:00 UTC</td>
<td><a href="/movies/1">More about Aladdin</a></td>
</tr>
Thank you!
The problem is not with the steps you have defined here as such, but that you have defined a step elsewhere that conflicts with one of these. You should either reuse that step if it makes sense here or create a step that doesn't conflict.
As michaeltwofish said. You probably have a step defined that does the same thing. Try removing one of the steps.
If you have duplicate methods/definitions. Meaning a definition with "And" and another definition with "Then" that does the same thing count as the same method.
And/When/Then/Given are basically the same thing. They server only to make the user story flow im a much more readable manor
Hope this additional info helped.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.