mercredi 7 janvier 2015

Protractor: Finding the right element to test

I think I'm misunderstanding how elements works..


HTML code:



<div id="div-item">
<a href="#">A link</a>
<form>
<div>
<select>
<option>1</option>
<option>2</option>
</select>
</div>
</form>
</div>


When I do this:



element(by.tagName('select')).all(by.tagName('option')).count();


This gives me 2, which is correct


When I do this:



element(by.id('div-item')).element(by.tagName('select')).all(by.tagName('option')).count();


This gives me 0. I thought chaining elements finds sub-elements. Is this not correct? How do I restrict the .all(by.tagName('option')) only within this div, rather than the whole page?


Aucun commentaire:

Enregistrer un commentaire