【发布时间】:2014-07-23 01:52:36
【问题描述】:
我正在用 capybara 编写一个 selenium 测试并尝试填写一个弹出框。我无法在水豚中使用 fill_in 方法填写元素的名称。这适用于其他页面中的其他表单,但不适用于此页面。
这是我的测试代码:
describe "Jobs" do
before do
login(users(:admin))
end
it "creates a job on a workspace" do
visit('#/workspaces')
click_button "Create Workspace"
within_modal do
fill_in 'name', :with => "testing-jobs"
click_button "Create Workspace"
end
click_link "Dismiss the workspace quick start guide"
page.should have_content('All Activity')
Workspace.find_by_name("testing-jobs").should_not be_nil
click_link "Jobs"
click_button "Create"
within('#facebox') do
find(".name").click
fill_in '. name', :with => "real job"
choose "onDemand"
click_button "Create"
end
page.should have_content "real job"
end
end
关于工作空间的第一个填充工作非常好,但是当我开始工作时,它就搞砸了。
这是来自 firebug 的实际开发代码:
<div id="facebox" class="dialog_facebox" style="top: 30px; left: 424.5px;">
<div class="popup" style="max-height: 626px;">
<div class="content">
<div class="configure_job_dialog dialog">
<div class="dialog_header">
<div class="errors"></div>
<div class="dialog_content" data-template="configure_job_dialog">
<form action="#">
<label class="required">Name</label>
<input class="name" type="text" value="">
我在 fill_in 方法中使用名称类,但水豚没有捕捉到它。我尝试进行更多调试,以了解为什么创建了我的工作区而不是工作。工作区代码如下。
<input type="text" maxlength="256" tabindex="1" placeholder="Name this workspace" name="name">
非常感谢任何帮助。
【问题讨论】:
标签: css selenium css-selectors capybara