量角器无法使用webdriver-manager在Chome中执行测试用例

时间:2019-03-04 18:36:30

标签: protractor

量角器无法使用webdriver-manager在chrome浏览器中启动测试用例。

我按照此处https://www.protractortest.org/#/的说明进行操作 并遇到以下错误。

debarnab@debarnab-Aspire-A515-51G:~/ProtractorConnectionTesting$ protractor conf.js
[19:33:57] I/launcher - Running 1 instances of WebDriver
[19:33:57] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[19:33:57] E/launcher - unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-45-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 59 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'debarnab-Aspire-A515-51G', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-45-generic', java.version: '1.8.0_201'
Driver info: driver.version: unknown
[19:33:57] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-45-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 59 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'debarnab-Aspire-A515-51G', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-45-generic', java.version: '1.8.0_201'
Driver info: driver.version: unknown
    at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
    at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
    at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:626:16)
    at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
    at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
    at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
    at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
[19:33:57] E/launcher - Process exited with error code 199

conf.ts文件

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js']
};

规格文件

describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {
    browser.get('https://angularjs.org');

    element(by.model('todoList.todoText')).sendKeys('write first protractor test');
    element(by.css('[value="add"]')).click();

    var todoList = element.all(by.repeater('todo in todoList.todos'));
    expect(todoList.count()).toEqual(3);
    expect(todoList.get(2).getText()).toEqual('write first protractor test');

    // You wrote your first test, cross it off the list
    todoList.get(2).element(by.css('input')).click();
    var completedAmount = element.all(by.css('.done-true'));
    expect(completedAmount.count()).toEqual(2);
  });
});

我正在使用Ubutu机器并尝试运行基本方案。如前所述,Selenium Server似乎已在http://localhost:4444/中启动并运行。有人可以建议吗?

3 个答案:

答案 0 :(得分:0)

进行如下配置

exports.config = {
      directConnect: true,

      // Capabilities to be passed to the webdriver instance.
      capabilities: {
        'browserName': 'chrome'
      },

      // Framework to use. Jasmine is recommended.
      framework: 'jasmine',

      // Spec patterns are relative to the current working directory when
      // protractor is called.
      specs: ['example_spec.js'],

      // Options to be passed to Jasmine.
      jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
      }
    };

从项目文件夹中运行npm i webdriver-managerwebdriver-manager update

如果尝试运行测试运行No Update config found时遇到node node_modules/protractor/bin/webdriver-manager update错误

现在运行测试

希望它对您有帮助

答案 1 :(得分:0)

this answer看来,您可以在Linux计算机上运行时添加--disable-dev-shm-usage来解决此问题。

conf.js

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js'],
  capabilities: [
    {
      browserName: 'chrome',
      chromeOptions: { args: ["--disable-dev-shm-usage"] },
    },    
};

您可以尝试一下,让我知道它是否有效吗?谢谢

答案 2 :(得分:0)

尝试使用以下Chrome浏览器arg运行您的作业:

 --capabilities.chromeOptions.args="no-sandbox"