Skip to content

Instantly share code, notes, and snippets.

@chrisyour
Created January 17, 2011 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisyour/782422 to your computer and use it in GitHub Desktop.
Save chrisyour/782422 to your computer and use it in GitHub Desktop.
A custom Cucumber web step that looks for existing links
# 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