Why does chaining selectors in Protractor return false when using isPresent

馋奶兔 提交于 2019-12-23 03:22:11

问题


So I'm writing automation tests for Ionic 2/Angular 2 and I have DOM element that looks like this

<ion-segment-button class="segment-button segment-activated" role="button" tappable="" value="orders" aria-pressed="true">

and I've created a page object that looks like this:

ordersButton: element(by.css('[value="orders"]')),

and in my spec file my test step looks like so

expect((orders.header.ordersButton).element(by.css('.segment-activated')).isPresent()).toBeTruthy();

this returns false and I can't figure out why. Any ideas?


回答1:


You may need to wait for the presence of the element:

var EC = protractor.ExpectedConditions;

var button = orders.header.ordersButton;
var segmentActivated = button.element(by.css('.segment-activated'));
browser.wait(EC.presenceOf(segmentActivated), 5000);

expect(segmentActivated.isPresent()).toBe(true);


来源:https://stackoverflow.com/questions/35921828/why-does-chaining-selectors-in-protractor-return-false-when-using-ispresent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!