I am trying to select an item from a dropdown using capybara.
The dropdown is a nested item generated using the cocoon gem. Both the css id and name are dynamically generated.
A copy/paste of the page source looks like this:
<div class="form-group select required protocol_step_items_orientation_id col-sm-3" title="Select an orientation for the plane of imaging." data-toggle="tooltip" data-placement="auto" data-delay="{"show":700,"hide":100}" data-animation="true">
<div class="col-sm-9">
<select id="protocol_step_items_attributes_1432720278702_orientation_id" class="select required form-control" name="protocol[step_items_attributes][1432720278702][orientation_id]">
<option value="">Orientation</option>
<option value="74">Axial</option>
<option value="75">Sagittal</option>
<option value="76">Coronal</option>
<option value="77">Sagital Oblique</option>
<option value="78">Coronal Oblique</option>
<option value="79">Axial Oblique</option>
</select>
</div>
</div>
What syntax can I give to a capybara finder to select from:
<select id="protocol_step_items_attributes_1432720278702_orientation_id" class="select required form-control" name="protocol[step_items_attributes][1432720278702][orientation_id]">
EDIT: This code generates the select box:
<div class="links" >
<div class="row">
<%= link_to_add_association 'Add Imaging Step', f, :step_items, :wrap_object => Proc.new{|item| item=StepItem.new}, :class=>"btn btn-primary btn-xs add_imaging_step", title: "Click here to add an imaging step.", data: {toggle: "tooltip", placement: "right", animation: true, delay: {show: 700, hide: 100}}%>
<%= link_to_add_association 'Add an Imaging Step List', f, :step_lists, :wrap_object => Proc.new{|item| item=StepList.new}, :class=>"btn btn-primary btn-xs",title: "Click here to add an imaging step list.", data: {toggle: "tooltip", placement: "right", animation: true, delay: {show: 700, hide: 100}}%>
<%= link_to_add_association 'Add an Imaging Tip', f, :tips, :class=>"btn btn-primary btn-xs", title: "Click here to add an imaging tip.", data: {toggle: "tooltip", placement: "right", animation: true, delay: {show: 700, hide: 100}}%>
<%= link_to_add_association 'Add an Image', f, :images, :class=>"btn btn-primary btn-xs", title: "Click here to add an image.", data: {toggle: "tooltip", placement: "right", animation: true, delay: {show: 700, hide: 100}}%>
<%= link_to_add_association 'Add a Document', f, :documents, :class=>"btn btn-primary btn-xs", title: "Click here to add a document.", data: {toggle: "tooltip", placement: "right", animation: true, delay: {show: 700, hide: 100}}%>
</div><!--row-->
EDIT2: I think the answer may be here:
Testing fields added dynamically by cocoon using rspec and capybara
or here:
Selecting element from dropdown without id Capybara
... but I can not seem to figure out the correct syntax to give the capybara finder.