Skip to content

Instantly share code, notes, and snippets.

@Overbryd
Forked from kilaulena/js_steps.rb
Created July 7, 2011 22:19
Show Gist options
  • Save Overbryd/1070678 to your computer and use it in GitHub Desktop.
Save Overbryd/1070678 to your computer and use it in GitHub Desktop.
Test capybara visibility
Then /^"([^"]+)" should not be visible(?: within "([^\"]*)")?$/ do |text, selector|
wait_until do
its_hidden = page.evaluate_script("$('#{selector}:contains(#{text})').is(':hidden');")
its_not_in_dom = page.evaluate_script("$('#{selector}:contains(#{text})').length == 0;")
(its_hidden || its_not_in_dom).should be_true
end
end
Then /^"([^"]+)" should be visible(?: within "([^\"]*)")?$/ do |text, selector|
wait_until do
its_hidden = page.evaluate_script("$('#{selector}:contains(#{text})').is(':hidden');")
its_not_in_dom = page.evaluate_script("$('#{selector}:contains(#{text})').length == 0;")
(its_hidden || its_not_in_dom).should be_false
end
end
When I follow "¥ JPY"
Then "¥ JPY" should be visible within ".header_nav"
And "€ EUR" should not be visible within ".header_nav"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment