首页 文章

Protularctor e2e测试在AngularJS / Anuglar 6 Hybrid应用程序中运行得非常快

提问于
浏览
0

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

我所有现有的测试都运行得非常快 . 并且大多数e2e测试现在都失败了,例如“元素不可见”或“元素未启用”,所以现在我已经在多个位置添加等待元素以修复它们 . 他们跑得太快的原因是什么?我有数百个测试用例,并且在测试用例中等待是一项耗时的任务 .

我用它来传递的任何其他设置,因为那些在Angular JS only app中运行正常 .

在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

    您不需要在测试中的每个操作之前添加服务员 . 您可以使用一些常见操作实现包装器 . 看看这个想法:

    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();
      }
    

    我希望你明白这个主意 .

相关问题