Skip to content

Instantly share code, notes, and snippets.

@skamithi
Created January 1, 2013 18:21
Show Gist options
  • Save skamithi/4429127 to your computer and use it in GitHub Desktop.
Save skamithi/4429127 to your computer and use it in GitHub Desktop.
Cucumber steps to check if search field is cleared but is still focused after the clear.
When /^I click the clear search button$/ do
find('#search_icon').click
end
Then /^the search field should be focused$/ do
page.execute_script <<-JS
if (jQuery('#search_form input[type=search]').is(':focus')) {
jQuery('#search_form').append("<div id='search_form_is_focused' />");
}
JS
page.should have_selector('#search_form_is_focused')
end
Then /^the search field should be empty$/ do
page.should have_selector('#search_form input[type=search]', :text => '')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment