简体   繁体   English

Angularjs量角器E2E测试'应用程序已经使用此元素进行自举

[英]Angularjs Protractor E2E test 'App Already Bootstrapped with this Element'

I am running into an issue where my Protractor tests always fail with the error message: 我遇到了一个问题,我的量角器测试总是失败并显示错误消息:

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">'

The current Angularjs docs suggest the issue is when the application is being manually bootstrapped, whereas in my case, this is not the case, we are just using: 目前Angularjs文档建议问题是手动引导应用程序时,而在我的情况下,情况并非如此,我们只是使用:

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

The normal site works fine, without an error or warning, but as soon as I set up my tests using Protractor the error occurs. 普通网站工作正常,没有错误或警告,但是一旦我使用Protractor设置我的测试,就会发生错误。 To note, the test was passing when I was using angularjs 1.08, but has since failed when using 1.25 需要注意的是,当我使用angularjs 1.08时测试正在通过,但是在使用1.25时失败了

The test is like so: 测试是这样的:

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);
    });

});

}); });

*note actual login details removed for safety. *请注意为了安全起见,删除了实际的登

As soon as the: browser.get('#/campaigns'); 一旦:browser.get('#/ campaigns');

is called, the error happens. 被调用,错误发生。

I have also tried using the login functionality as an onPrepare in the protractor conf file, but the same thing happens. 我也尝试使用登录功能作为量角器conf文件中的onPrepare,但同样的事情发生了。

Any thoughts or help would be appreciated! 任何想法或帮助将不胜感激!

Full stack trace: 完整堆栈跟踪:

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 ' caused by 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 // Continue to bootstrap Angular.\\n angular.resumeBootstrap(arguments[0]);\\n }).apply(null, arguments);\\"}","url":"/execute","urlParsed":{"anchor":"","query":"","file":"execute","directory":"/","path":"/execute","relative":"/execute","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute","queryKey":{},"chunks":["execute"]},"urlOriginal":"/session/64b440e0-68b9-11e3-b92a-e1efe36914bc/execute"} Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00' System 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“,”方法“:”POST“,”post“:”{\\“args \\”:[[]],\\“script \\”:\\“return(function(){\\ n //继续引导Angular。\\ n angular .resumeBootstrap(arguments [0]); \\ n})。apply(null,arguments); \\“}”,“url”:“/ execute”,“urlParsed”:{“anchor”:“”,“query” : “”, “文件”: “执行”, “目录”: “/”, “路径”: “/执行”, “相对的”: “/执行”, “端口”: “”, “宿主”:” ”, “密码”: “”, “用户”: “”, “用户信息”: “”, “权威”: “”, “协议”: “”, “源”: “/执行”, “queryKey”: {},“chunks”:[“execute”]},“urlOriginal”:“/ session / 64b440e0-68b9-11e3-b92a-e1efe36914bc / execute”}构建信息:版本:'2.37.0',修订版:'a7c61cb ',时间:'2013-10-18 17:14:00'系统 info: host: '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' info:host:'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'

I have come across similar situation yesterday and was able to resolve this by adding a browser.ignoresynchronisation = true before each test. 我昨天遇到过类似情况,并且能够通过在每次测试之前添加browser.ignoresynchronisation = true来解决此问题。 This happens if you bootstrap your Angular app manually using resumeBootstrap. 如果您使用resumeBootstrap手动引导Angular应用程序,则会发生这种情况。 I also needed to make the browser to sleep for some time to have the actual results come through. 我还需要让浏览器睡一段时间以获得实际结果。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM