I'm trying to test my inline editable elements using capybara and poltergeist, on Rails 4, Bootstrap 3, and Boostrap-editable-rails 0.0.7, and following the examples in the x-editable docs. Capybara seems to click on the elements but their conversion to the form element never takes place. It works fine when going through the UI in dev mode.
我正在尝试使用capybara和poltergeist,在Rails 4,Bootstrap 3和Boostrap-editable-rails 0.0.7上测试我的内联可编辑元素,并遵循x-editable docs中的示例。 Capybara似乎点击元素,但他们转换为表单元素永远不会发生。在开发模式下通过UI时,它工作正常。
<a class="edit_form" id="edit-note-category-<%= jira.id %>" href="#" data-type="select"
data-source="<%=@note_categories%>" data-value="<%=note.note_category.try(:id) %>"
data-resource="note" data-name="note_category_id" data-pk="<%=note.id%>"
data-url="/correct/path">
</a>
# CUCUMBER STEP DEFINITIONS
When(/^I click the element for the (.*?)$/) do |element|
element = element.downcase.gsub(' ', '-')
elem_id = "#edit-#{element}-#{@jira.id}"
find(elem_id).trigger('click')
end
When(/^I change the note's category to "(.*?)"$/) do |category_name|
select category_name
end
The test for this fails with an ElementNotFound exception when trying to select the category name. The html in dev mode shows a select is created after the element is clicked, but a screenshot mid-test after the same action shows no such select element.
尝试选择类别名称时,对此测试失败并出现ElementNotFound异常。在开发模式下的html显示在单击元素后创建选择,但在相同操作之后的屏幕截图中间显示没有这样的选择元素。
1 个解决方案
#1
0
I know its been a long time since you asked this question, but I stumbled on this when experiencing what is probably the same issue. I had setup X-Editable to make a PATCH request when updating a field. This worked fine in production/development but when we wanted to add a feature spec for it we had difficulty. I tested it using the selenium driver, that worked too. The issue was clearly with using Poltergeist.
我知道自从你提出这个问题以来已经很久了,但在遇到可能同样的问题时我偶然发现了这个问题。我在更新字段时设置了X-Editable来发出PATCH请求。这在生产/开发中运行良好,但是当我们想为它添加功能规格时,我们遇到了困难。我使用硒驱动器测试了它,它也有效。问题显然是使用了Poltergeist。
It turns out, there is currently a bug with PhantomJS (the underlying engine for Poltergeist) with making PATCH requests (https://github.com/ariya/phantomjs/issues/11384). While it would be nice to have and more semantic, my solution was to change the request to a PUT.
事实证明,PhantomJS(Poltergeist的底层引擎)目前存在一个错误,即发出PATCH请求(https://github.com/ariya/phantomjs/issues/11384)。虽然拥有更多语义会很好,但我的解决方案是将请求更改为PUT。
Something like this:
像这样的东西:
function enableInlineEditable() {
$('.inline-editable').editable({
ajaxOptions: { type: 'PUT' },
});
}
#1
0
I know its been a long time since you asked this question, but I stumbled on this when experiencing what is probably the same issue. I had setup X-Editable to make a PATCH request when updating a field. This worked fine in production/development but when we wanted to add a feature spec for it we had difficulty. I tested it using the selenium driver, that worked too. The issue was clearly with using Poltergeist.
我知道自从你提出这个问题以来已经很久了,但在遇到可能同样的问题时我偶然发现了这个问题。我在更新字段时设置了X-Editable来发出PATCH请求。这在生产/开发中运行良好,但是当我们想为它添加功能规格时,我们遇到了困难。我使用硒驱动器测试了它,它也有效。问题显然是使用了Poltergeist。
It turns out, there is currently a bug with PhantomJS (the underlying engine for Poltergeist) with making PATCH requests (https://github.com/ariya/phantomjs/issues/11384). While it would be nice to have and more semantic, my solution was to change the request to a PUT.
事实证明,PhantomJS(Poltergeist的底层引擎)目前存在一个错误,即发出PATCH请求(https://github.com/ariya/phantomjs/issues/11384)。虽然拥有更多语义会很好,但我的解决方案是将请求更改为PUT。
Something like this:
像这样的东西:
function enableInlineEditable() {
$('.inline-editable').editable({
ajaxOptions: { type: 'PUT' },
});
}