如果html看起来如下:
<form>
<div>
<field-component>
<div class='field'></div>
</field-component>
</div>
<div>
<div class='icon'></div>
</div>
</form>
我可以使用fieldElement = element(by.css('.field'))
获取字段,但如何才能获得与icon
类最接近的元素?
答案 0 :(得分:1)
试试这个:
var form = element(by.css('form'));
return form.element(by.css('.field')).isPresent().then((present) => {
if (present) {
return form.element(by.css('.icon')).click(); #click or whatever on this element
}
});