我的角度应用程序中有一个e2e量角器测试.我只是连续几次运行完全相同的测试,并且它通过了大约5%的时间,在下面的屏幕截图中没有错误.
考试:
it('should open the cart with the cart button in the header',() => { page.navigateTo('/calendar/day/(dmy:27-9-2018)'); page.cartButton().click(); expect(element(by.css('h2.cart-header')).isPresent()).toBe(true); });
量角器暂停启动的chrome实例显示单击按钮并且存在h2元素(请参见底部的图像).
我试过了什么
>我已使用模拟数据替换了此组件中的数据,以消除异步操作
>我禁用了动画
>我试图使其成为异步函数:… header’,async()=> {…
>我试过等待(ing)元素:expect(等待元素(by.css(‘h2.cart …)
>我试过浏览器.sleep(1000)
>我尝试了各种断言,如.toBe(true),. toEqual(true)和.toBeTruthy()
错误消息:
解决方法
请使用browser.ignoreSynchronization = true;