- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在运行一个脚本,使用 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);
}
};
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/
我有一个表,其中包含3行数据和3个删除按钮。我想删除所有数据行,因此想在我的页面对象中编写一个方法来做到这一点……这应该很简单,但我无法使其正常工作。我正在这样尝试: this.rows = elem
我们有一个应用程序,在本地进行测试会显示无效的SSL证书警告。通常,我只添加一个异常并继续处理。但是, Protractor 有无视这一点吗? 我已经看到了 Selenium 中的一些功能,其中可以忽
我有一个关于我的代码和不同行为的问题,具体取决于使用的 Protractor 版本。 我的测试使用 Protractor 版本 2.5.1。但要从最新发展中获得所有好处,我 试图移动到版本 3.x。
我有一个项目已经运行了很长时间。 最近(几周)系统测试失败了。 经过大量调查,我们得出结论, Protractor 无法识别和关闭警报。 曾经工作的代码 exports.removeFaq = fun
我能够成功运行 Protractor 脚本。下面是我用来运行 Protractor 脚本的 protractor.config.js 文件。 var Jasmine2Reporter = requir
在 Protractor 中,如何处理重复的内容,比如一张表格?例如,给定以下代码,它会踢出一个包含 3 列的表:Index , Name和 Delete-Button在每一行中: {{$in
我为 Protractor 编写了一个自定义定位器,可以找到 anchor元素由他们 ui-sref值(value)。在我的规范中,我刚刚使用了 by.addLocator添加自定义定位器,但我认为发
我遇到过 Protractor 的页面对象的不同类型的语法,我想知道它们的背景是什么以及建议采用哪种方式。 这是 Protractor 教程中的官方 PageObject 语法。我最喜欢它,因为它清晰
Protractor 中有两个 it() 测试用例 it('it1',function(){ }); it('it2',function(){ }); 完成 it1 后, Protractor 中的驱
我目前正在运行一套 Protractor 测试。我有一个 config.js 仅设置为运行具有“功能”的 Chrome。见下文。 capabilities: { } browserNa
我试图断言名称显示在表的列中。我写了一个 inResults将遍历列的文本以查看名称是否存在的函数。这是我正在尝试的: 页面对象: this.names = element.all(by.repeat
我可以使用检索浏览器日志 browser.manage().logs().get('browser').then(function(browserLog) { logger.info('log:
我按照文档中有关如何安装 Protractor 和 Selenium 的说明进行操作,但无法启动。 install -g protractor webdriver-manager update 之后我
我在 Protractor 中使用 --suites config 运行多个案例。我必须为每种情况重新启动我的 web 应用程序,但我的应用程序有一个警报,每当页面重新加载或关闭时,都会弹出该警报以进
我想知道如何在测试套件中按顺序运行测试用例。 例如,加载 URL、登录系统等。 最佳答案 检查 protractor.conf.js example . 您可以指定一个按字母顺序加载文件的 glob,
row1Col1 row1Col2 row1Co
如何从包含特定文本的转发器中搜索元素? 我试过这样的事情: element(by.repeater('item in array')).all(by.cssContainingText('.xyz',
只是想知道是否可以将 cli args 指定为 Protractor --multiCapabilities.0.browserName chrome --multiCapabilities.1.br
是否可以在 Protractor 中的任何套件运行之前运行一些测试或逻辑流程? 例如,我想将我的 Protractor 测试分解成一系列套件来测试我的应用程序的不同方面。假设 Jenkins 将在部署
我是 Protractor 的新手,我正在尝试使用 Protractor 设置单选按钮值。我在互联网和 SO 上搜索了徒劳的答案。 html: No Yes
我是一名优秀的程序员,十分优秀!