我正在尝试测试 jquery UI 自动完成功能,我已经使用 selenium 驱动程序通过了测试.我想切换到 poltergiest 进行一些无头测试,但现在我的测试失败了.
I'm trying to test an jquery UI autocomplete, I've got the tests passing using the selenium driver. I want to switch to poltergiest for some headless testing, but now my tests are now failing.
由于某种我还没有弄清楚的原因,它似乎没有选择自动完成选项
It doesn't seem to select the autocomplete option for some reason that I have yet been able to figure out
步骤
When /^select contract$/ do
VCR.use_cassette("contract") do
selector =
'.ui-menu-item a:contains("John Smith (123456)")'
within("div#review") do
fill_in("contract", with: "john")
end
sleep 2
page.execute_script "$('#{selector}').trigger("mouseenter").click();"
within("div#myPerformaceReview") do
find_field("contract").value.should ==
"John Smith (123456)"
end
end
end
使用 Selenium 驱动程序通过了测试,没有对步骤进行任何更改.
The test passes using the Selenium driver without any changes to the step.
关于如何调试此问题的任何建议?
Any advice on how I could debug this?
版本
selenium-webdriver (2.27.2)poltergeist (1.0.2)黄瓜 (1.2.1)黄瓜导轨 (1.0.6)水豚 (1.1.4)phantomjs 1.8.1推荐答案
我已经弄清楚了,似乎 capybara-poltergeist 驱动程序没有触发 jquery-ui 用来显示下拉列表的任何事件.
I've managed to figure it out, it seems capybara-poltergeist driver doesn't trigger any of the events that jquery-ui uses to display the dropdown list.
我在这里找到了答案:https://github.com/thoughtbot/capybara-webkit/issues/50
我在 features/support
module FormHelper
def fill_in_autocomplete(selector, value)
page.execute_script %Q{$('#{selector}').val('#{value}').keydown()}
end
def choose_autocomplete(text)
find('ul.ui-autocomplete').should have_content(text)
page.execute_script("$('.ui-menu-item:contains("#{text}")').find('a').trigger('mouseenter').click()")
end
end
World(FormHelper)
然后我使用这些方法填写表格并选择所需的选项.
I then used those method to fill in the form and select the desired option.
相关推荐
最新文章