gpt4 book ai didi

javascript - Protractor Debug模式给出 "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory"

转载 作者:搜寻专家 更新时间:2023-11-01 00:42:17 27 4
gpt4 key购买 nike

我正在运行一个脚本,使用 NodeJS 0.12.4、Protractor 2.1.0 自动登录网页,我的系统是 Win 8.1、i7 2.5 GHz、16 GB RAM,所以我认为不太可能我的内存用完了!仅供引用,当我评论代码中的所有语句但 browser.get() 时,我在开始时使用 browser.pause() 在交互模式下一个一个地执行它们时,代码有效。这是 spec.js 文件的代码:

 describe('Web Page Login', function() {
it('should login', function() {
browser.get('http://URL_HERE'); // opens page

//browser.pause();

element(by.css('[ng-click="showLogin(true);"]')).click();// clicks the login link to open the login dialog


var user = element(by.model('user.login.username'));// input user name
user.sendKeys('user');

var pass = element(by.model('user.login.password')); // input password
pass.sendKeys('pass');

element(by.css('[ng-click="login();"]')).click();// clicks the login button

var userName = element(by.className('ng-binding'));// locates the logged in user from the player details element and store it in "userName"
userName.getText(); //extracts the text that contains the user name

expect(userName).toBe("user"); //compare the string obtained above with the one expected

});
});

这是 conf.js 文件的代码:

var HtmlReporter = require('protractor-html-screenshot-reporter');

var reporter=new HtmlReporter({
baseDirectory: './results', // the location to store the screen shots and results.
docTitle: 'Login test result',
docName: 'login-tests-report.html'
});


exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['login-spec.js'],
onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
}
};
不幸的是,我不能发布我们网站的 URL,因为它是内部的,如果需要 HTML,我可以发布一些片段。所以如果我尝试运行它输入

protractor conf.js

没有评论所有行我得到这个错误:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

但是,如果我注释掉 spec.js 中除 browser.get() 之外的所有行,并且我使用 repl 进入调试交互模式,并且我如上所述逐行键入代码中的每一行,我可以执行所有代码到最后没有错误。两周前我开始使用 Protractor 和 JavaScript,所以我可能会错过一些东西。感谢您的帮助。

最佳答案

在与我的一位开发人员讨论后,我想出了如何使代码正常工作,而不是触发该错误的原因,我怀疑它可能来自 Node 库。改变我执行断言的方式消除了错误。这是有效的代码:

describe('Web Page Login', function() {
it('should login', function() {
browser.get('http://URL_HERE');//opens Web page

element(by.css('[ng-click="showLogin(true);"]')).click();//clicks the login link to open the login dialog

element(by.model('login.user.login.username')).sendKeys('username');//input user name
element(by.model('login.user.login.password')).sendKeys('password');//input password
element(by.css('[ng-click="login.login(false, loginForm.$valid);"]')).click(); //clicks the login button

var userName = element(by.className('ng-binding'));// locates the logged in user from the player details element and store it in "userName"
expect(userName.getText()).toContain('username');//compares the string found with the one expected and asserts if it's true or false
});
});
如果我能找出根本原因,我会在此处发布。

关于javascript - Protractor Debug模式给出 "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30536861/

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