【问题标题】:waitForAngularEnable(true) NOT working - ScriptTimeoutError: script timeout: result was not received inwaitForAngularEnable(true) 不工作 - ScriptTimeoutError:脚本超时:未收到结果
【发布时间】:2019-10-21 23:34:06
【问题描述】:

起始页角度。通过单击一个按钮将导致登录页面是无角度的。登录后,其余页面都是有角度的。

我正在使用 async/await。

  • 在 onPrepare 中包含 waitForAngularEnable(true) 但不起作用。
  • 尝试在登录后添加waitForAngularEnable(true) 但这没有 工作。
  • 尝试增加timeOut,但也没有用。
  • 仅在 waitForAngularEnable(false) 时有效。我不能使用量角器 waiForAngular 中的内置功能,它等到 angular 加载。目前使用 waitForAngularEnable(false) 我正在使用 browser.driver.wait(until.elementsLocated(by.id(value)), 30000); 手动处理它或等待 browser.wait(ExpectedConditions.presenceOf(ele), 30000);。这样就可以了。

版本-
“量角器”:“^5.4.2”
“节点”:10.15.3
“目标”:“es6”
“黄瓜”:“^5.1.0”,
"cucumber-html-reporter": "^5.0.0"
ScriptTimeoutError: script 超时:30 秒内未收到结果
(会话信息:chrome=74.0.3729.169)
(驱动程序信息:chromedriver=74.0.3729.6
(255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17763 x86_64) 在 Object.checkLegacyResponse
(C:\Automation\General\node_modules\selenium-webdriver\lib\error.js:546:15) 在 parseHttpResponse (C:\Automation\General\node_modules\selenium-webdriver\lib\http.js:509:13)
在 doSend.then.response (C:\Automation\General\node_modules\selenium-webdriver\lib\http.js:441:30)
在 process._tickCallback (internal/process/next_tick.js:68:7) 来自:任务:Protractor.waitForAngular() - 定位器:By(xpath, //span[@class='title__subtext'])

【问题讨论】:

  • 如果它有效,那么你的问题是什么。您必须为非 Angular 页面设置 waitForAngularEnable(false)。
  • 我不能使用量角器 waiForAngular 中的内置功能,它等到 angular 加载。目前使用 waitForAngularEnable(false) 我正在使用 browser.driver.wait(until.elementsLocated(by.id(value)), 30000); 手动处理它或等待 browser.wait(ExpectedConditions.presenceOf(ele), 30000);。这样就可以了。

标签: angular typescript protractor cucumber


【解决方案1】:

对于 Angular 应用,Protractor 将等到Angular Zone 稳定。这意味着长时间运行的异步操作将阻止您的测试继续进行。要解决此问题,请在 Angular 区域之外运行以下任务。

您可能需要将此超时设置为补丁,直到问题在应用程序级别得到解决

allScriptsTimeout: 60000

找到了一篇很好的文章: https://valor-software.com/articles/testing-with-protractor-how-to-fix-synchronization-issues.html

【讨论】:

    【解决方案2】:

    可以在同一个测试中多次使用waitForAngularEnabled,但需要不明显地添加browser.get。您可以使用以下内容:

    // do things on your Angular application
    
    waitForAngularEnabled(false)
    
    // do things on non-angular page
    
    waitForAngularEnabled(true)
    browser.get('/home') // this is a page from your Angular application
    

    browser.get 函数在加载 Angular 页面之前一直阻塞。

    【讨论】:

      【解决方案3】:

      你在做什么(根据我对你问题的理解)

      • 打开角度页面
      • 登录
      • 您被重定向到非角度页面(此时量角器已经没有响应)
      • 您尝试await browser.waitForAngularEnabled(false);(但量角器没有响应,因为您在非角度页面上)

      你应该做什么

      • 打开角度页面
      • 输入凭据
      • 在你点击提交按钮之前运行await browser.waitForAngularEnabled(false);
      • 您被重定向到非角度页面(此时量角器可以与其通信)
      • 做任何你想做的事

      简单地说,您必须禁用等待 Angular WHILE 您仍在 Angular 页面上

      附:反之亦然。如果您从非 Angular 页面导航回 Angular,则必须仅在您登陆 Angular 页面时启用该功能

      【讨论】:

        猜你喜欢
        • 2018-03-13
        • 1970-01-01
        • 2019-09-14
        • 1970-01-01
        • 2019-11-11
        • 2019-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多