samedi 11 juin 2016

Protractor: Using a where clause with a collection of elements

I want to return the child divs closest to the parent of an element.

HTML

<div id='Parent'>
  <div>
    <div></div>
  </div>
  <div>
    <div></div>
    <div></div>
    <div></div>
  </div>
</div>

Protractor

var parent = element(by.id('Parent'));
var topChildren = parent.all(by.tagName('div')).then(elem => [elem[0], elem[1]]); //this doesn't work.

I know the logic here might be wrong (would the top two elements really be the top children?) but I don't think this is even returning an array of elements. For instance, topChildren.getAttribute('class') throws a topChildren.getAttribute is not a function so it doesn't even see the return as a collection of elements.

Aucun commentaire:

Enregistrer un commentaire