Skip to content

Instantly share code, notes, and snippets.

@buru
Created June 7, 2013 15:00
Show Gist options
  • Save buru/5729885 to your computer and use it in GitHub Desktop.
Save buru/5729885 to your computer and use it in GitHub Desktop.
Select the first item from Ajax-Chosen field using Capybara with Selenium web driver
def select_from_ajax_chosen(item_text, field_id)
within "##{field_id}_chzn" do
find('a.chzn-single').click
input = find("div.chzn-search input")
item_text.each_char do |char|
input.native.send_keys char
end
sleep 1
input.native.send_keys :arrow_down
input.native.send_keys :return
within 'a.chzn-single' do
page.should have_content item_text
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment