我正在尝试通过名称填写字段。因为在 2 种不同的形式中有两个具有相同名称的字段,所以我不能单独使用 fill_in,因为存在不明确的匹配。
我正在尝试执行如下所示的操作,但显然内部并没有按名称查找,因此它找不到表格。
When(/^I type "(.*?)" into the "(.*?)" textbox in the "(.*?)" form$/) do |textboxValue, textboxName, textboxForm|
within(:name, textboxForm) do
fill_in textboxName, :with => textboxValue
end
end
texboxForm - 元素所在的表单名称 textboxName - 文本框的名称 textboxValue - 我想要填充文本框的值
有什么想法吗? 谢谢
最佳答案
这有点可怕,但这很有效。
find("form[name='" + textboxForm + "']").fill_in textboxName, :with => textboxValue
关于ruby - Capybara - 使用参数在表单中填写表单元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19808966/