【发布时间】:2019-05-17 20:56:54
【问题描述】:
我是量角器的新手。我按照https://www.protractortest.org/#/ 中提到的步骤进行操作 当我运行命令 protractor conf.js 时,浏览器会立即打开和关闭。 我在命令行中收到以下错误:
[22:41:08] E/launcher - 进程退出,错误代码为 100
我尝试通过在 conf.js 中添加功能在 Firefox 中执行
文件内容:
spec.js
import { element } from "protractor";
describe('angularjs homepage todo list', function() {
it('should add a todo', async function() {
await browser.get('https://angularjs.org');
await element(by.model('todoList.todoText')).sendKeys('write first protractor test');
await element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(await todoList.count()).toEqual(3);
expect(await todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
await todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(await completedAmount.count()).toEqual(2);
});
});
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
//useAllAngular2AppRoots: true,
//directConnect=true,
/* capabilities: {
'browserName': 'firefox'
} */
};
【问题讨论】:
-
你能从你的conf文件中发布
onPrepare()吗? It appears 如果其中有问题,可能会发生此错误。 -
我的 conf.js 有以下代码:exports.config = { seleniumAddress: 'localhost:4444/wd/hub', specs: ['todo-spec.js'] };
-
自最新的 Protractor 版本以来,本教程的文档似乎没有更新。如果您使用 6.0 以上的 Protractor 版本,您将需要自己处理框架的异步特性(最好使用
async/await样式)。虽然我不确定这是否是您的问题的原因,但这是开始解决此问题的好地方
标签: protractor