cucumber - List child elements for a Capybara/Poltergeist element -


i've searched around , can't find way this.

we running capybara tests poltergeist driver in cucumber features on emberjs/rails app. can't use page.driver.debug because i'm running inside headless vagrant instance, troubleshooting not available me, screenshots work, , chrome dev tools inspect on page in question shows right elements.

i have cucumber scenario that's failing, , it's because find isn't working. test looks this:

when(/^i delete description "(.*?)"$/) |description|   within :css, '#myform'     first('label', :text => /#{description}/).find(:xpath, '..').find(:css, 'button.delete')   end end 

it can't find element in question. here relevant section of dom:

<form id="myform">   <div class="row-fluid question">       <div class="span12">         <div class="padding">           <div id="ember576" class="ember-view is-viewing-edit-controls">             <button class="delete" data-ember-action="31"></button>             <button class="edit" data-ember-action="32"></button>             <button class="insert_above" data-ember-action="33"></button>             <button class="insert_below" data-ember-action="34"></button>             <button class="move_up" data-ember-action="35"></button>             <button class="move_down" data-ember-action="36"></button>             <label class="question" data-ember-action="37">enter first name</label>             <input id="ember577" class="ember-view ember-text-field">             <span class="error"></span>           </div>         </div>     </div>   </div> </form> 

if add in binding.pry, this:

first('label', :text => /#{description}/).find(:xpath, '..')                                                                                               │ 

gives me response:

=> #<capybara::element tag="div"> 

and this:

first('label', :text => /#{description}/).find(:xpath, '..')                                                                                               │ 

gives me response:

=> "enter first name" 

but full find:

first('label', :text => /#{description}/).find(:xpath, '..').find(:css, 'button.delete') 

gives me response:

capybara::elementnotfound: unable find css "button.delete" 

i have feeling parent/sibling issue, can't troubleshoot it. guess have couple of questions:

  1. for debugging, there anyway poltergeist driver list child elements?
  2. is there wrong xpath selector? fact .. returning capybara::element tag="div" makes me think have right parent element (and said, works on other pages in other similar tests), have no way verify element is. can't find how xpath or else helps me identify element.

i figured out. test working fine, missing action step in scenario.

however, thought y'all might find useful know how ended getting contents: executing jquery on page. added binding.pry test, , in binding.pry console logged jquery result, e.g.:

# gave me expected contents , verified button.delete child page.execute_script("console.log($('#myform label.question').parent().html())");  # , gave me classes demonstrate correct div page.execute_script("console.log($('#myform label.question').parent().attr('class'))"); 

i took shortcut selectors because knew label looking first one, selector doesn't matter, it's idea of console.log()-ing jquery in binding.pry useful.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -