Autocomplete @javascript测试使用selenium驱动程序通过,但使用poltergiest时失败
我正在尝试测试jQueryUI自动完成,我已经使用selenium驱动程序通过了测试。我想切换到poltergiest进行一些无头测试,但现在我的测试失败了 它似乎没有选择autocomplete选项,原因我还没有弄清楚 步骤Autocomplete @javascript测试使用selenium驱动程序通过,但使用poltergiest时失败,autocomplete,cucumber,capybara,phantomjs,poltergeist,Autocomplete,Cucumber,Capybara,Phantomjs,Poltergeist,我正在尝试测试jQueryUI自动完成,我已经使用selenium驱动程序通过了测试。我想切换到poltergiest进行一些无头测试,但现在我的测试失败了 它似乎没有选择autocomplete选项,原因我还没有弄清楚 步骤 When /^select contract$/ do VCR.use_cassette("contract") do selector = '.ui-menu-item a:contains("John Smith (123456)")'
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驱动程序测试通过,步骤没有任何更改
关于如何调试这个有什么建议吗
版本
- selenium webdriver(2.27.2)
- 恶鬼(1.0.2)
- 黄瓜(1.2.1)
- 黄瓜轨道(1.0.6)
- 水豚(1.1.4)
- 幻影JS 1.8.1
- 我已经设法弄明白了,似乎水豚怪精灵驱动程序不会触发jquery ui用来显示下拉列表的任何事件
我在这里找到了答案:
我在功能/支持中创建了一个表单帮助器
然后,我使用这些方法填写表格并选择所需选项。马丁的回答几乎对我有效,但我发现输入也需要集中精力才能使其有效:
module FormHelper
def fill_in_autocomplete(selector, value)
page.execute_script %Q{$('#{selector}').focus().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
在同一页上发现:此测试在哪一行失败?当我断言该字段应包含来自自动完成:find_字段(“合同”)的文本时。value.should==“John Smith(123456)”。page.execute_脚本似乎无法正确启动。
module FormHelper
def fill_in_autocomplete(selector, value)
page.execute_script %Q{$('#{selector}').focus().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