gpt4 book ai didi

javascript - 在 Protractor 中查找UI元素并不一致。使用本地主机而不是服务器

转载 作者:行者123 更新时间:2023-11-28 10:43:19 26 4
gpt4 key购买 nike

这是我正在使用的代码expect(element(by.id('title')).getAttribute('value')).toMatch('Sample Title')

在本地计算机上它工作得很好,在服务器上它没有出现以下错误。

Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: By(css selector, *[id="title"])

令人惊讶的是,有时当我单独执行这些测试时,它们在服务器上运行。

添加到问题中。我观察到 Protractor 在测试中只能找到一个元素,其余所有元素都被忽略,并出现上述错误。

解决这个问题的方法是什么?

最佳答案

这可能是应用程序问题。有时, Angular 永远不会向 Protractor 报告所有任务都已完成,因此您可能会收到此超时错误。

http://www.protractortest.org/#/timeouts

AngularJS If your AngularJS application continuously polls $timeout or $http, Protractor will wait indefinitely and time out. You should use the $interval for anything that polls continuously (introduced in Angular 1.2rc3).

Angular For Angular apps, Protractor will wait until the Angular Zone stabilizes. This means long running async operations will block your test from continuing. To work around this, run these tasks outside the Angular zone. For example:

this.ngZone.runOutsideAngular(() => { setTimeout(() => { // Changes here will not propagate into your view. this.ngZone.run(() => { // Run inside the ngZone to trigger change detection. }); }, REALLY_LONG_DELAY); }); As an alternative to either of these options, you could disable waiting for Angular, see below.

关于javascript - 在 Protractor 中查找UI元素并不一致。使用本地主机而不是服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48114389/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com