Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save albertoperdomo/508514 to your computer and use it in GitHub Desktop.
Save albertoperdomo/508514 to your computer and use it in GitHub Desktop.
Feature: Cool AJAX autocomplete
Scenario: Autocomplete city
When I fill in "City" with "Madr"
Then I should see "Madrid, Spain"
When I follow "Madrid, Spain"
Then the field "City" should contain "Madrid, Spain"
Feature: Cool AJAX autocomplete
Scenario: Autocomplete city
When I fill in "City" with "Madr"
Then I should see the following autocomplete options:
| Madrid, Spain |
| Madridejos, Spain |
When I click on the "Madrid, Spain" autocomplete option
Then the field "City" should contain "Madrid, Spain"
Feature: Cool AJAX autocomplete
Scenario: Autocomplete city
When I fill in "City" with "Madr"
Then I should see the following autocomplete options:
| Madrid, Spain |
| Madridejos, Spain |
When I follow "Madrid, Spain"
Then the field "City" should contain "Madrid, Spain"
Feature: Cool AJAX autocomplete
Scenario: Autocomplete city
When I fill in "City" with "Madr"
And I wait for 2 seconds
Then I should see "Madrid, Spain"
When I follow "Madrid, Spain"
Then the field "City" should contain "Madrid, Spain"
When /^I click on the "([^"]*)" autocomplete option$/ do |link_text|
# this should work in future versions but no in current stable
# page.evaluate_script %Q{ $('.ui-menu-item a:contains("#{link_text}")').trigger("mouseenter").click(); }
page.execute_script %Q{ $('.ui-menu-item a:contains("#{link_text}")').trigger("mouseenter").click(); }
end
Then /^I should see the following autocomplete options:$/ do |table|
# table is a Cucumber::Ast::Table
table.raw.each do |row|
locate(:xpath, "//a[text()='#{row[0]}']")
end
end
When /^I wait for (\d+) seconds?$/ do |secs|
sleep secs.to_i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment