【发布时间】:2020-10-26 12:52:44
【问题描述】:
我有 3 个选项卡,我需要测试它们是否被点击,但我似乎找不到一个好的预期条件来使用。现在我正在使用浏览器。睡眠时间更长,因为标签需要几秒钟才能加载。
标签:
代码:
let locator = {
upcomingTabButton : element(by.css('div.toolbar-content.toolbar-content-md ion-segment ion-segment-button:nth-child(1)')),
pendingTabButton : element(by.css('div.toolbar-content.toolbar-content-md ion-segment ion-segment-button:nth-child(2)')),
completedTabButton : element(by.css('div.toolbar-content.toolbar-content-md ion-segment ion-segment-button:nth-child(3)')),
activeTab : element(by.css('ion-segment ion-segment-button.segment-button.segment-activated')),
upcomingActiveTab: element(by.cssContainingText('ion-segment ion-segment-button.segment-button.segment-activated', 'UPCOMING')),
};
describe('When x tab button is pressed, ', function () {
it('if x = PENDING tab, then it should be activated', () => {
browser.sleep(1000);
browser.wait(EC.elementToBeClickable(locator.pendingTabButton),5000);
locator.pendingTabButton.click();
browser.sleep(10000);
expect(element(by.css('ion-segment ion-segment-button.segment-button.segment-activated')).getText()).toEqual('PENDING');
});
it('if x = UPCOMING tab, then it should be activated', () => {
browser.wait(EC.elementToBeClickable(locator.upcomingTabButton),5000);
locator.upcomingTabButton.click();
//browser.wait(EC.presenceOf(locator.upcomingActiveTab),5000);
browser.sleep(10000);
expect(element(by.css('ion-segment ion-segment-button.segment-button.segment-activated')).getText()).toEqual('UPCOMING');
});
it('if x = COMPLETED tab, then it should be activated', () => {
browser.wait(EC.elementToBeClickable(locator.completedTabButton),5000);
locator.completedTabButton.click();
//browser.wait(EC.presenceOf(locator.activeTab),5000);
browser.sleep(10000);
expect(element(by.css('ion-segment ion-segment-button.segment-button.segment-activated')).getText()).toEqual('COMPLETED');
});
});
我尝试了一些预期的条件,但没有任何效果,因为我需要查看选项卡何时被选中,而我没有找到任何类似的 exp 条件。
我用browser.sleep(10000) 10秒,不过这样,不是很好用。
谁能帮帮我?
标签内容加载大约需要 5/6 秒
【问题讨论】:
标签: android html ionic-framework automation protractor