简体   繁体   中英

E2E test fail error: cannot find chrome binary in Linux

I'm setting up e2e tests (protractor) for a gitlab-ci pipeline using angular and actually I'm new to this topic. I want the tests to be headless also because the server where the Gitlab-ci is, is running on Linux.

But I always get this error:

E/launcher - unknown error: cannot find Chrome binary.

For me it makes no sense because it compiles successfully and also downloading, unzipping the Chromedriver and also got 1 running instance of Webdriver but then it crashes with mentioned error.

Also what I should mention is that it works local but when I push it, it doesn't.

I already tried some things I found like editing protractor.conf.js with '--no-sandbox' but it doesn't work for me.

Here you can see my protractor.conf.js

const {SpecReporter} = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './src/**/*.e2e-spec.ts'
  ],
  capabilities: {
    browserName: 'chrome', chromeOptions: {
      args: [
        '--headless',
        '--disable-gpu',
        '--window-size=800,600',
      ]
    }
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function () {
    }
  },
  onPrepare() {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    });
    jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
  }
};

I hope you guys can help me with my problem and I thank you very much in advance for your answer.

If your Chrome is not installed in the standard location, you may have to explicitly specify it in your protractor.conf.js:

capabilities: {
    'browserName': 'chrome',
    "chromeOptions": {
      binary: "/Applications/your_path/Google Chrome.app/Contents/MacOS/Google Chrome"
    },
  },

OR

You can use chromeoptions:

ChromeOptions ChromeOptions = new ChromeOptions();
ChromeOptions.addArguments("--headless", "window-size=1024,768", "--no-sandbox");
driver = new ChromeDriver(ChromeOptions);

fixed it by installing chrome on the linux server didnt find an other solution

I removed the binary field in chromeOptions and it found the installed Chrome on MacOS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM