public

  • Download Gist
autocomplete_scenario_at_start.feature
Cucumber
1 2 3 4 5 6 7
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"
autocomplete_scenario_clicking_options.feature
Cucumber
1 2 3 4 5 6 7 8 9
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"
autocomplete_scenario_locating_options.feature
Cucumber
1 2 3 4 5 6 7 8 9
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"
autocomplete_scenario_waiting_for_options.feature
Cucumber
1 2 3 4 5 6 7 8
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"
clicking_autocomplete_options.rb
Ruby
1 2 3 4 5
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
locate_autocomplete_options_step.rb
Ruby
1 2 3 4 5 6
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
waiting_step.rb
Ruby
1 2 3
When /^I wait for (\d+) seconds?$/ do |secs|
sleep secs.to_i
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.