Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
Created June 21, 2013 13:35
Show Gist options
  • Save bogdanRada/5831183 to your computer and use it in GitHub Desktop.
Save bogdanRada/5831183 to your computer and use it in GitHub Desktop.
def test_autocomplete(field, options = {})
fill_in field, :with => options[:with]
page.execute_script("$('##{field}').trigger('focus');")
page.execute_script ("$('##{field}').trigger('keydown');")
selector = "span.tt-dropdown-menu div.tt-suggestion:contains('#{options[:select]}')"
page.should have_selector selector
page.execute_script("$(\"#{selector}\").mouseenter().click()")
page.should have_field(field, :with => options[:select])
end
scenario "typeahead test" do
test_autocomplete("platform_primary_domain",{:with=> "1.com", :select => "domain_name_1.com"})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment