waitForAngularEnable(true)不工作-ScriptTimeoutError:脚本超时:中未收到结果

waitForAngularEnable(true)不工作-ScriptTimeoutError:脚本超时:中未收到结果,angular,typescript,protractor,cucumber,Angular,Typescript,Protractor,Cucumber,起始页有角度。点击一个按钮将进入无角的登录页面。登录后,其余的页面是有角度的 我正在使用async/await 在onPrepare中包含waitForAngularEnable(true),但不起作用 尝试在登录后添加waitForAngularEnable(true),但没有成功 工作 尝试增加超时时间,但效果不佳 仅当waitForAngularEnable(false)时有效。我不能使用量角器WAIFORANGLAR中的内置功能,它要等到角度加载。目前使用waitForAngularE

起始页有角度。点击一个按钮将进入无角的登录页面。登录后,其余的页面是有角度的

我正在使用async/await

  • 在onPrepare中包含
    waitForAngularEnable
    (true),但不起作用
  • 尝试在登录后添加
    waitForAngularEnable
    (true),但没有成功 工作
  • 尝试增加
    超时时间
    ,但效果不佳

  • 仅当
    waitForAngularEnable
    (false)时有效。我不能使用量角器WAIFORANGLAR中的内置功能,它要等到角度加载。目前使用waitForAngularEnable(false),我正在使用browser.driver.wait(直到.elementsLocated(by.id(value)),30000)手动处理它;或者等待browser.wait(ExpectedConditions.presenceOf(ele),30000);。这样就行了
版本-“量角器”:“^5.4.2”
“节点”:10.15.3
“目标”:“es6”
“黄瓜”:“^5.1.0”,
“Cumber html reporter”:“^5.0.0”
ScriptTimeoutError:脚本 超时:30秒内未收到结果
(会话信息:chrome=74.0.3729.169)
(驱动程序信息:chromedriver=74.0.3729.6
(255758eccf3d244491b8a1317aa76e1ce10d57e9参考/分支头/3729@{29}),平台=窗口 新界10.0.17763 x86_64) 在Object.checkLegacyResponse
(C:\Automation\General\node\u modules\selenium webdriver\lib\error.js:546:15) 在parseHttpResponse(C:\Automation\General\node\u modules\selenium webdriver\lib\http.js:509:13)上
在doSend.then.response(C:\Automation\General\node\u modules\selenium webdriver\lib\http.js:441:30)
在进程中。_tick回调(内部/process/next_tick.js:68:7) From:Task:dragrator.waitForAngular()-Locator:By(xpath,//span[@class='title\uu subtext'])


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

  • 打开有角度的页面
  • 登录
  • 您被重定向到非角度页面(此时量角器已无响应)
  • 您尝试
    wait browser.waitForAngularEnabled(false)(但量角器不响应,因为您处于非角度页面)
你应该做什么

  • 打开有角度的页面
  • 输入凭据
  • 单击提交按钮之前,运行
    等待浏览器。waitForAngularEnabled(false)
  • 您被重定向到非角度页面(此时量角器可以与其通信)
  • 做你想做的事
简单地说,当您仍在angular页面上时,必须禁用等待angular


另请注意,反之亦然。如果您正在从非角度页面导航回角度页面,则必须仅在登录角度页面时启用该功能,使用
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

浏览器.get
功能块,直到加载角度页面。

对于角度应用程序,量角器将等待
角度区域
稳定。这意味着长时间运行的异步操作将阻止测试继续。要解决此问题,请在角度区域之外运行以下任务

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

allScriptsTimeout: 60000
找到一篇关于此的好文章:

如果有效,您的问题是什么。您必须为非角度页面设置waitForAngularEnable(false)。我无法使用量角器WaitForAngular中的内置功能,它将等待角度加载。目前使用waitForAngularEnable(false),我正在使用browser.driver.wait(直到.elementsLocated(by.id(value)),30000)手动处理它;或者等待browser.wait(ExpectedConditions.presenceOf(ele),30000);。这样就行了。