Note that there are some explanatory texts on larger screens.

plurals
  1. POCapybara rspec inconsistent behaviour when trying to click buttons / submit forms
    primarykey
    data
    text
    <p>This is something that leads me to waste hours and I wish I knew why. I've found lots of examples (not all answered) where forms are not being submitted, it works on a webpage, but not in capybara. things like find/xpath work in the irb. </p> <p><strong>web page</strong> file box with a upload button, attaching the file works (i'm using poltergeist render to see that file name is attached)</p> <p><strong>debugging / options tried</strong></p> <ul> <li>find () works e.g. in irb it returns an object: Capybara Element tag=input</li> <li>if i attempt to "visit '' it returns {"status"=>"fail", "click"=>{"x"=>124, "y"=>283}} [nothing in the log that action called. DEFINITELY works in development environment]</li> <li>click_on 'Upload' fails: {"status"=>"fail", "click"=>{"x"=>124, "y"=>283}}</li> <li>find_button('Upload').click: {"status"=>"fail", "click"=>{"x"=>124, "y"=>283}}</li> <li>find("#upload_bill_button1").trigger("click"): returns "click"</li> <li>i have tried exec_script of javascript checkBill() . page.execute_script('checkBill()'): returns nil</li> <li>find(:css, '#upload_bill_button1').click . returns: {"x"=>124, "y"=>282}</li> </ul> <p>nothing in the logs to show the action is being completed</p> <p>i have</p> <ul> <li>js=>true as its a javascript submit (does a test first, code below).</li> <li>made sure all ids are unique</li> <li>capybara::DSL added</li> </ul> <p>system setup</p> <ul> <li>Mac ox X</li> <li>poltergeist (working for all my other tests)</li> <li>ruby 1.9.3</li> <li>phantom 1.9.2</li> </ul> <p>is there further debug to figure out the problem ? other logs i'm missing? any guidance much appreciated</p> <pre><code> &lt;div class="row"&gt; &lt;div class="large-10 columns" &gt; &lt;%=form_tag( "/upload_bill", :method=&gt;:post, :multipart =&gt; true, :id =&gt; "form_upload1") do -%&gt; &lt;fieldset&gt; &lt;legend&gt;Select your bill file&lt;/legend&gt; &lt;%=file_field_tag 'bill', :onclick =&gt; "checkBill()" -%&gt; &lt;div class="large-2 columns" &gt; &lt;!-- TODO: make the browse button the zurb class type --&gt; &lt;%- if params[:action].eql?( 'index')%&gt; &lt;%=submit_tag "Upload", :onclick =&gt; "checkBill();return false;", :id =&gt; "upload_bill_button1", :class =&gt; "button postfix" -%&gt; &lt;% end %&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;% end %&gt; &lt;/div&gt; &lt;/div&gt; &lt;%- if params[:action].eql?('import_bill')%&gt; &lt;%=link_to (image_tag "/images/btn-uploadbill.png"), "#", :onclick=&gt;"checkBill();return false;", :id =&gt; "upload_bill_button2" -%&gt; &lt;%=link_to (image_tag "/images/btn-cancel.png"), root_path %&gt; &lt;%- end %&gt; &lt;script type="text/javascript"&gt; function checkBill(){ var bill = $("#bill").val(); if(bill.split('.').reverse()[0]=="csv"||bill.split('.').reverse()[0]=="pdf"||bill.split('.').reverse()[0]=="pdftranslatedtxt"){ //success bill supported, data send to app jQuery('#form_upload1').submit(); } else if(bill==""){return false; } else{// return error wrong format of bill alert('We only currently support PDF or CSV file format.') } } &lt;/script&gt; </code></pre> <p><strong>UPDATE</strong> I have the code working on some instance of this page. I have also have one situation where the find/trigger is working (the logs show actions, but the poltergeist:render shows no page update)</p> <p>so, rspec function is</p> <pre><code>def new_import_bill(billfile) path = DATA_TEST+billfile attach_file("bill", path) find("#upload_bill_button1").trigger("click") end </code></pre> <p>I have debugged the page output e.g.</p> <pre><code>puts page.html </code></pre> <p>and there is no difference between the page html that works and the pages that do not work., but in certain situations it refuses to click or the poltergeist.render does not update.</p> <p>as per this poltergeist bug (<a href="https://github.com/jonleighton/poltergeist/issues/209" rel="nofollow">https://github.com/jonleighton/poltergeist/issues/209</a>) I have tried removing full:true. No difference</p> <p>has anyone else come across these inconsistences?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload