@javascript黄瓜测试通过使用硒驱动程序,但无法使用poltergiest时 [英] @javascript cucumber tests pass using selenium driver but fail when using poltergiest
问题描述
我想测试一个jQuery用户界面自动完成,我得使用硒驾驶员通过考试。我想切换到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
测试通过使用硒司机没有任何改变的步骤。
The test passes using the Selenium driver without any changes to the step.
这是我怎么能调试这有何建议?
Any advice on how I could debug this?
版本
- 硒的webdriver(2.27.2)
- 骚灵(1.0.2)
- 黄瓜(1.2.1)
- 黄瓜轨(1.0.6)
- 水豚(1.1.4)
- phantomjs 1.8.1
推荐答案
我已经设法弄清楚,似乎水豚,骚灵驱动程序不会触发任何的jQuery的用户界面用来显示下拉列表中的事件。
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的/问题/ 50
I found the answer here: https://github.com/thoughtbot/capybara-webkit/issues/50
我创建一个表单辅助的功能/支持的
I created a form helper in 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.
这篇关于@javascript黄瓜测试通过使用硒驱动程序,但无法使用poltergiest时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!