gpt4 book ai didi

javascript - Angularjs Protractor E2E 测试 'App Already Bootstrapped with this Element'

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:44:48 24 4
gpt4 key购买 nike

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

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

被调用,错误发生。

我也曾尝试在 Protractor 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(null , 参数);\"}","url":"/execute","urlParsed":{"anchor":"","query":"","file":"execute","directory":"/","路径":"/执行","相对":"/执行","端口":"","主机":"","密码":"","用户":"","userInfo":"","authority":"","protocol":"","source":"/execute","queryKey":{},"chunks":["execute"]},"urlOriginal":"/ session /64b440e0-68b9-11e3-b92a-e1efe36914bc/执行"}构建信息:版本:'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'

最佳答案

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

希望对你有帮助

关于javascript - Angularjs Protractor E2E 测试 'App Already Bootstrapped with this Element',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20684457/

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