AngularJs 应用程序的量角器定位器超时异常

Protractor Locator Time Out exception for AngularJs application

我们正在尝试自动化一个可公开访问的网站并单击其中一个 link,但在定位元素时测试失败并出现超时异常:

发件人:任务:Protractor.waitForAngular() - 定位器:通过(link 文本,我的帐户) 下面的示例 conf 和规范文件。 请求有关如何解决此问题的帮助。

conf.js

exports.config = {
                seleniumAddress: 'http://localhost:4444/wd/hub',
                capabilities: {
                                'browserName': 'chrome'
                },             
                specs: ['test.js']
};

test.js

describe('test', function() {

                it('should navigate', function(done) {
                                browser.get('https://ww2.tracfone.com');
                                element(by.linkText('MY ACCOUNT')).click();
                                done();
                });
};

我根据您发布的项目设置了一个示例项目,此测试似乎适用于 me.I我不确定为什么您会遇到通常与未关联的页面相关联的超时angular 但设置 browser.ignoreSynchronization = true 有助于克服此错误。

var ec = protractor.ExpectedConditions;
var timeout = 60000;

describe('test', function() {
    it('should navigate', function(done) {

        browser.ignoreSynchronization = true;
        browser.get('https://ww2.tracfone.com')

        var myAccount = element(by.linkText('MY ACCOUNT'));
        browser.wait(ec.visibilityOf(myAccount)).then(function() {
            myAccount.click();
        })
        done();
    });
});

找到您在网页上看到的问题的根本原因。看起来您的站点持续轮询 $timeout 或 $http,Protractor 将无限期等待并超时。

我监控了下面的 http 流量,发现您的应用频繁轮询,Protractor 只是等待。查看下面的屏幕截图。(时间轴中的绿色标记表示 $http 调用 - https://ww2.tracfone.com/cgi-bin/tealeaf.pl

关于您看到此错误的原因的更多详细信息是 documented here。行。对此有不同的解决方案,有多种解决方法。我只会简单地谈谈备选方案,然后让您选择最佳方案。

  1. IgnoreSynchronization:在 browser.get() 之前将此标志 - browser.ignoreSynchronization 设置为 false 并继续测试流程并再次将其他页面的标志设置为 true 检查 here

  2. Interval.js : I am no expert on this but you can explore more here

You should use the $interval for anything that polls continuously (introduced in Angular 1.2rc3).

  1. 尝试不同的超时配置,看看您的应用轮询是否会在一段时间后停止

    allScriptsTimeout:120000, getPageTimeout:120000, 茉莉花节点选项:{ 默认超时间隔:120000 }