我维护一个复杂的Angular(1.5.x)应用程序,使用Protractor(2.5.x)进行E2E测试。我遇到了这种方法的问题,主要表现在测试看起来很脆弱的方式。在一个拉取请求中完美运行的测试在另一个拉取请求中失败。这涉及简单的定位器,例如by.linkTest(...)。我调试了失败的测试,应用程序位于正确的页面上,链接存在且可访问。
I maintain a complex Angular (1.5.x) application that is being E2E tested using Protractor (2.5.x). I am experiencing a problem with this approach, which presents primarily in the way the tests seem flaky. Tests that worked perfectly well in one pull request fail in another. This concerns simple locators, such as by.linkTest(...). I debugged the failing tests and the app is on the correct page, the links are present and accessible.
还有其他人遇到过这些一致性问题吗?了解原因或解决方法?
Has anyone else experienced these consistency problems? Knows of a cause or workaround?
推荐答案只是拒绝更多的端到端测试!
那就是说,你可以采取一些措施来解决我们共同无情的诡异敌人:
That said, here are the few things you can do to tackle our mutual merciless "flakiness" enemy:
- 更新到最新的量角器(目前为4.0.0),它还带来了最新的 selenium 和 chromedriver with it
- 关闭Angular动画
-
使用龙 browser.wait( ) ,其中包含一组内置或自定义预期条件。这可能是迄今为止解决问题的最可靠方法。不幸的是,这是用例和特定问题,您需要在有问题的地方修改您的实际测试。例如,如果您需要单击某个元素,请等待它可以点击:
- update to the latest Protractor (currently 4.0.0) which also brings latest selenium and chromedriver with it
- turn off Angular animations
use dragons browser.wait() with a set of built-in or custom Expected Conditions. This is probably by far the most reliable way to approach the problem. Unfortunately, this is use-case and problem specific, you would need to modify your actual tests in the problematic places. For example, if you need to click an element, wait for it to be clickable:
最大化浏览器窗口(以避免随机元素不可见或者不是可点击的错误)。把它放到 onPrepare():
maximize the browser window (to avoid random element not visible or not clickable errors). Put this to onPrepare():
browser.driver.manage().window().maximize();
还有其他特定问题的技巧,例如在文本框中输入,点击通过JavaScript 等。
There are also other problem-specific "tricks" like slow typing into the text box, clicking via JavaScript etc.
更多推荐
量角器片状
发布评论