Skip to content

Instantly share code, notes, and snippets.

@richdownie
Created May 26, 2011 17:28
Show Gist options
  • Save richdownie/993572 to your computer and use it in GitHub Desktop.
Save richdownie/993572 to your computer and use it in GitHub Desktop.
(selenium-webdriver + cucumber + rspec) equivalence to watir contains_text?
FEATURE:
Scenario: Google Landing Page
* I am on the google page
* I should see "About Google"
* I should NOT see "Fidel Castro"
STEPS:
Given /I should (NOT )?see "(.*)"/ do |visibility, what|
result = @browser.find_elements(:xpath, "//*[text()='" + what + "']")
if (visibility.to_s.strip == 'NOT') then
result.count.should == 0
p ("#{result.count}" + " text matches found")
else
result.count.should >= 1
p ("#{result.count}" + " matching text strings found")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment