I’m currently in the process of writing a selenium test using capybara, and I’ve encountered an issue when trying to populate a pop-up box. Specifically, I am unable to input the element’s name using the fill_in method in capybara. Strangely, this method works smoothly on other forms and pages, except for this particular one.
Below is a snippet of my test code:
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"
</div>
page.should have_content "real job"
end
end
The first fill_in method regarding workspaces functions flawlessly, but as soon as I transition to jobs, everything falls apart.
Here's the developer code from 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="">
Despite utilizing the name class in the fill_in method, capybara doesn’t seem to detect it. I attempted further debugging to determine why the workspace is created successfully, yet not the job. The workspace’s code is shown below.
<input type="text" maxlength="256" tabindex="1" placeholder="Name this workspace" name="name">
Any assistance would be greatly appreciated.