Angular:量角器 – count()没有解析并导致超时
我正在尝试简单地计算我的旋转木马e2e组件测试
carousel.po.ts import { browser,element,by,Key } from 'protractor'; export class CarouselDemoPage { navigateTo() { return browser.get('/design/carousel'); } getCarouselComponent(index: number) { return element.all(by.css('cfc-carousel')).get(index); } getCarouselIndicators(index: number) { return this.getCarouselComponent(index).element(by.css('.indicators')).all(by.repeater('item in items')); } } 我的spec文件: import { CarouselDemoPage } from './carousel.po'; describe('Carousel component',() => { let page: CarouselDemoPage; beforeEach(() => { page = new CarouselDemoPage(); page.navigateTo(); }); it('At least one carousel component should exist',() => { expect<any>(page.getCarouselComponent(0)).toBeDefined(); }); it('Check correct number of indicators displayed',() => { expect<any>(page.getCarouselIndicators(0).count()).toEqual(4); }); }); 我有最新的或接近最新的至少包
第一次测试运行正常,第二次测试结束时间 1)轮播组件检查显示的正确指示器数量 在等待带定位符的元素时 – Locator:By(css selector,cfc-custom-select) 放弃 ngAfterViewInit() { // Needs the timeout to avoid the "expression has changed" bug setTimeout(() => { this.items = this.viewItems.toArray().concat(this.contentItems.toArray()); this.totalItems = this.items.length; this._first = this.items[0]; this._last = this.items[this.totalItems - 1]; this._setItemsOrder(this.currentFrame); this._setInterval(); },0); } 因此,我尝试了 browser.ignoreSynchronization = true; 和 browser.driver.sleep(50); 和 browser.waitForAngular(); 但后来我把数量计算为0 所以经过一些调试后我发现我的轮播组件中的setInterval会破坏测试 我应该使用browser.ignoreSynchronization = true; ?? 有任何想法吗?
因此,由于carousel组件中的setInterval和其他超时功能,我需要添加
browser.ignoreSynchronization = true; 我稍微修改了我的getCarouselIndicators函数 getCarouselIndicators(index: number) { browser.ignoreSynchronization = true; return this.getCarouselComponent(index).all(by.css('.indicators li')); } 现在测试解决并完美运行! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |