4

我遇到了一个问题,我的量角器测试总是失败并显示错误消息:

UnknownError: Error Message => '[ng:btstrpd] App Already Bootstrapped with this Element '<html lang="en" data-ng-app="pmApp" class="js draganddrop no-video no-audio ng-scope">'

当前的 Angularjs 文档表明问题出在手动引导应用程序时,而在我的情况下,情况并非如此,我们只是使用:

<html lang="en" data-ng-app="pmApp">

正常站点工作正常,没有错误或警告,但是一旦我使用 Protractor 设置测试,就会发生错误。需要注意的是,当我使用 angularjs 1.08 时测试通过了,但在使用 1.25 时失败了

测试是这样的:

describe('Campaigns page', function() {
var ptor;

beforeEach(function() {
    // Sets the width of the window, otherwise the default min width
    // of our site is to small and the login page un-usable
    browser.driver.manage().window().setSize(1200, 800);
    ptor = protractor.getInstance();

    browser.driver.get(ptor.baseUrl + '/login');

    browser.driver.findElement(by.id('user_email')).sendKeys('admin@aperture.*************.com');
    browser.driver.findElement(by.id('user_password')).sendKeys('*************');

    browser.driver.findElement(by.css('.button.primary')).click();

    browser.driver.wait(function() {
        return browser.driver.getCurrentUrl().then(function(url) {
            return (/\/#\/$/.test(url));
        });
    });

    // Now ensure the angular app is loaded and it knows about it
    browser.get('#/');
});

it('Should list campaigns on the page', function() {
    browser.get('#/campaigns');

    browser.findElements(by.css('.main-campaign')).then(function(results) {
        expect(results.length).toBeGreaterThan(0);
    });

});

});

*请注意为安全起见已删除实际登录详细信息。

只要: browser.get('#/campaigns');

被调用,错误发生。

我也尝试在量角器 conf 文件中使用登录功能作为 onPrepare,但同样的事情发生了。

任何想法或帮助将不胜感激!

完整的堆栈跟踪:

Stacktrace:
 UnknownError: Error Message => '[ng:btstrpd] App Already Bootstrapped with this Element '<html lang="en" data-ng-app="pmApp" class="js draganddrop no-video no-audio ng-scope">'

http://errors.angularjs.org/1.2.5/ng/btstrpd?p0=%3Chtml%20lang%3D%22en%22%20data-ng-app%3D%22pmApp%22%20class%3D%22js%20draganddrop %20no-video%20no-audio%20ng-scope%22%3E' 由 Request => {"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"159","Content-Type ":"application/json; charset=utf-8","Host":"localhost:29064"},"httpVersion":"1.1","method":"POST","post":"{\"args \":[[]],\"script\":\"return (function () {\n // 继续引导 Angular。\n angular.resumeBootstrap(arguments[0]);\n }).apply(空, 参数);\"}","url":"/execute","urlParsed":{"anchor":"","query":"","file":"execute","directory": "/","路径":"/执行","relative":"/execute","port":"","host":"","password":"","user":"","userInfo":"","authority":"", "protocol":"","source":"/execute","queryKey":{},"chunks":["execute"]},"urlOriginal":"/session/64b440e0-68b9-11e3-b92a- e1efe36914bc/execute"} 构建信息:版本:'2.37.0',修订:'a7c61cb',时间:'2013-10-18 17:14:00' 系统信息:主机:'peters-mbp',ip:' 192.168.0.3',os.name:'Mac OS X',os.arch:'x86_64',os.version:'10.9',java.version:'1.6.0_65'密码":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute","queryKey":{}, "chunks":["execute"]},"urlOriginal":"/session/64b440e0-68b9-11e3-b92a-e1efe36914bc/execute"} 构建信息:版本:'2.37.0',修订:'a7c61cb',时间:'2013-10-18 17:14:00' 系统信息:主机:'peters-mbp',ip:'192.168.0.3',os.name:'Mac OS X',os.arch:'x86_64', os.version:'10.9',java.version:'1.6.0_65'密码":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute","queryKey":{}, "chunks":["execute"]},"urlOriginal":"/session/64b440e0-68b9-11e3-b92a-e1efe36914bc/execute"} 构建信息:版本:'2.37.0',修订:'a7c61cb',时间:'2013-10-18 17:14:00' 系统信息:主机:'peters-mbp',ip:'192.168.0.3',os.name:'Mac OS X',os.arch:'x86_64', os.version:'10.9',java.version:'1.6.0_65'"chunks":["execute"]},"urlOriginal":"/session/64b440e0-68b9-11e3-b92a-e1efe36914bc/execute"} 构建信息:版本:'2.37.0',修订:'a7c61cb',时间:'2013-10-18 17:14:00' 系统信息:主机:'peters-mbp',ip:'192.168.0.3',os.name:'Mac OS X',os.arch:'x86_64', os.version:'10.9',java.version:'1.6.0_65'"chunks":["execute"]},"urlOriginal":"/session/64b440e0-68b9-11e3-b92a-e1efe36914bc/execute"} 构建信息:版本:'2.37.0',修订:'a7c61cb',时间:'2013-10-18 17:14:00' 系统信息:主机:'peters-mbp',ip:'192.168.0.3',os.name:'Mac OS X',os.arch:'x86_64', os.version:'10.9',java.version:'1.6.0_65'

4

1 回答 1

0

我昨天遇到了类似的情况,并且能够通过在每次测试之前添加 browser.ignoresynchronisation = true 来解决这个问题。如果您使用 resumeBootstrap 手动引导您的 Angular 应用程序,就会发生这种情况。我还需要让浏览器休眠一段时间才能获得实际结果。

希望这可以帮助

于 2015-04-02T15:11:48.990 回答