Skip to content

Instantly share code, notes, and snippets.

@littlebee
Created February 17, 2012 20:06
Show Gist options
  • Select an option

  • Save littlebee/1855161 to your computer and use it in GitHub Desktop.

Select an option

Save littlebee/1855161 to your computer and use it in GitHub Desktop.
Test selector visible or not with cucumber
Then /^I should( not)? see selector "([^\"]*)"/ do |negate, selector|
wait_until do
its_hidden = page.evaluate_script("$('#{selector}').is(':hidden');")
its_not_in_dom = page.evaluate_script("$('#{selector}').length == 0;")
(its_hidden || its_not_in_dom).should (negate ? be_true : be_false)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment