【问题标题】:E/launcher - process exited with error code 100E/launcher - 进程退出,错误代码 100
【发布时间】: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


【解决方案1】:

正如我在评论中提到的,文档尚未更新以反映在最新版本中默认禁用控制流(以前用于处理量角器的异步特性)这一事实。现在有必要自己处理这些承诺,async/await 风格是最简单的长期。

以下是主站点中使用 async/await 样式的示例。

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

我不确定这是否是您的问题的原因,但这是开始进行故障排除的好地方。

注意:仅当您的量角器版本高于 6.0 时才会影响

【讨论】:

  • 当我使用'npm install -g protractor'安装量角器时,安装的版本是5.4.2
  • 哦,在这种情况下,这对您来说应该不是问题。如果您在问题中包含整个 todo-spec.js'conf.js 文件,这可能会有所帮助。
  • 您好 DublinDev,感谢您的关注。已添加相关代码。
  • 您可以尝试删除开头的导入行吗? Protractor 将在启动时自动执行这些导入,并且 NodeJS 目前不支持这种导入样式。这意味着您的代码需要转译才能使这种导入方式起作用,但是由于您使用的是 javascript 而不是 typescript,因此这不会自动发生。最好将其删除并再次尝试。此外,如果您使用的是 5.4.2 版和 async/await 样式,则需要在 conf 中包含 SELENIUM_PROMISE_MANAGER: false 以手动禁用控制流。
  • 感谢 DublinDev。删除导入行后,它现在可以工作了
猜你喜欢
  • 2018-03-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多