量角器waitForAngularEnabled

编程入门 行业动态 更新时间:2024-10-28 00:24:49
本文介绍了量角器waitForAngularEnabled的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

waitForAngularEnabled似乎不起作用.

waitForAngularEnabled doesn't seem to work.

用例: -将waitForAngularEnabled设置为false以获取sso页并填充用户/密码字段 -返回角度应用程序并将waitForAngularEnabled设置为true会导致错误

Use case : - waitForAngularEnabled to false to get sso page and fill user/password fields - return to angular app and waitForAngularEnabled to true causes error

我已经创建了一个简单的有角度的应用程序projet来再现它,并运行e2e

i've create a simple angular app projet to reproduce it, simple run ng e2e

github/lilletech/protractor-issue

推荐答案

为了调试和减轻量角器控制流程的问题,您应该进一步分解测试.将测试更改为以下工作:

You should break your tests up more, both for your sake with debugging and to mitigate issues with the protractor control flow. Changing your tests to the following works:

import { browser, element, by } from 'protractor'; describe('protractor-test-project App', () => { it('goes to google', () => { browser.waitForAngularEnabled(false); browser.get('www.google'); expect(browser.getCurrentUrl()).toEqual('www.google/'); }); it('enters a search', () => { const inputEl = element(by.id('lst-ib')); browser.wait(() => inputEl.isPresent(), 10000, 'too long'); inputEl.sendKeys("protractor issue waitForAngularEnabled"); expect(inputEl.getAttribute('value')).toEqual('protractor issue waitForAngularEnabled'); }); it('returns to angular page', () => { browser.get('/'); browser.waitForAngularEnabled(true); const titleElement = element(by.id("title")); expect(titleElement.isPresent()); }); });

不能肯定地说为什么控制流不能正确处理这个问题,但这似乎是由于在同一规范中有两个waitForAngularEnabled引起的(也可能是因为导航了两次).如果禁用第二个(重新启用它的位置),则测试有效.

Can't say for sure why the control flow wouldn't be handling this properly, but this seems to be caused by having two waitForAngularEnabled in the same spec (also might be because of navigating twice). If you disable your second one (where you re-enable it), your test works.

因此,您可以使用上面的解决方案将其分解为多个步骤,也可以将调用嵌套在browser.get下,这似乎也可以工作

So you can either use my solution above which breaks them out into multiple steps, or you can nest the call under browser.get which also seems to work i.e.

browser.get('/').then(() => { browser.waitForAngularEnabled(true); });

同样,不确定为什么会那样.控制流应该同步这些步骤,因此不必使用c2,但是显然如此.将测试分为多个it块也可以帮助量角器以正确的顺序同步事物

Again, not sure why exactly that would happen. The control flow should be synchronizing these steps so using .then() shouldnt be necessary... but apparently it is. Breaking tests out into multiple it blocks also helps protractor synchronize things in the proper order

更多推荐

量角器waitForAngularEnabled

本文发布于:2023-11-22 23:10:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619288.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:量角器   waitForAngularEnabled

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!