量角器e2e测试在AngularJS / Anuglar 6 Hybrid应用程序中运行非常快

时间:2018-07-14 06:25:40

标签: angularjs protractor angular6 angular-hybrid

我已经将Angular JS(1.5)应用程序迁移到了Hybrid应用程序。我正在同时使用Angular6 / AngularJS(1.6)。我正在尝试为角度js页面运行现有e2e测试的量角器e2e。

我所有现有的测试运行都非常快。并且大多数e2e测试现在由于诸如“元素不可见”或“未启用元素”之类的原因而失败,因此现在我在多个位置添加了等待元素来修复它们。他们为什么运行太快有什么原因?我有数百个测试用例,在测试用例中放置等待是一项耗时的工作。

我用来使它们通过的任何其他设置,因为这些设置在仅Angular JS的应用程序中运行良好。

在Angular JS应用程序中,我的量角器版本为“ 4.0.9”和“ webdriver-manager”:“ 10.2.3”。现在,在移至此处的角度混合应用程序后,该版本已更新

我的量角器版本:量角器“:” ^ 5.3.2 “ webdriver-manager”:“ 12.0.6”, “ selenium-webdriver”:“ 4.0.0-alpha.1”,

节点版本:`8.11.3 量角器版本:5.3.2 角版本:6.0.4 AngularJS版本:1.6.4 浏览器:Chrome,firefix

1 个答案:

答案 0 :(得分:0)

您无需在测试中的每个操作之前添加服务员。您可以通过一些常见的操作来实现包装器。看看这个想法:

public async clickOn(): Promise<void> {
    try {
      await this.waitForClickable();
    } catch (e) {
      throw new Error(`Can not click on fragment of not clickable fragment. ${e}`);
    }
    await this.click();
  }

  public async type(text: string): Promise<void> {
    await this.clearInput();
    await this.sendKeys(text);
  }

  public async clearInput(): Promise<void> {
    try {
      await this.waitForVisible();
    } catch (e) {
      throw new Error(`Can not clear the input of not visible fragment. ${e}`);
    }
    await this.clear();
  }

希望您能明白。