Created
January 17, 2011 02:42
-
-
Save chrisyour/782422 to your computer and use it in GitHub Desktop.
A custom Cucumber web step that looks for existing links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cucumber Step | |
Then /^I should see the link "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector| | |
matching_link = nil | |
with_scope(selector) do | |
all('a').each do |link| | |
matching_link = link if link.has_content?(text) | |
end | |
end | |
assert matching_link != nil, "No matching link was found" | |
end | |
# Usage | |
Scenario: | |
Given I am on the home page | |
Then I should see the link "Login" | |
# Alternate usage: | |
Given I am on the home page | |
Then I should see the link "Login" within "#navigation" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment