Permalink
Browse files

form: wait for the result when using autocomplete fields

  • Loading branch information...
1 parent d51f684 commit 0250c8537fa994dce68810a5f70561923c01564f @senny committed Mar 21, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/corner_stones/form.rb
@@ -43,7 +43,10 @@ def autocomplete(value, options)
fill_in(options[:in], :with => value)
page.execute_script %Q{ $('##{autocomplete_id}').trigger("focus") }
page.execute_script %Q{ $('##{autocomplete_id}').trigger("keydown") }
- sleep 1
+ wait_until do
+ result = page.evaluate_script %Q{ $('.ui-menu-item a:contains("#{value}")').size() }
+ result > 0
+ end
page.execute_script %Q{ $('.ui-menu-item a:contains("#{value}")').trigger("mouseenter").trigger("click"); }
end

0 comments on commit 0250c85

Please sign in to comment.