Testing JQuery autocomplete ui with cucumber

后端 未结 4 1031
借酒劲吻你
借酒劲吻你 2021-01-06 09:44

I got this cucumber sceanario:

When I fill in \"End User\" with \"john\"
Then wait
Then wait
When I click \"John Doe\"
Then show me the page
<
4条回答
  •  醉话见心
    2021-01-06 10:36

    Give this a go

    When /^I type in "([^\"]*)" into autocomplete list "([^\"]*)" and I choose "([^\"]*)"$/ do |typed, input_name,should_select|
       page.driver.browser.execute_script %Q{ $('input[data-autocomplete]').trigger("focus") }
       fill_in("#{input_name}",:with => typed)
       page.driver.browser.execute_script %Q{ $('input[data-autocomplete]').trigger("keydown") }
       sleep 1
       page.driver.browser.execute_script %Q{ $('.ui-menu-item a:contains("#{should_select}")').trigger("mouseenter").trigger("click"); }
    end
    

    Use like so

    And I type in "Foo" into autocomplete list "input_id" and I choose "Foobar"
    

提交回复
热议问题