WebDriverError: unknown error: cannot find Chrome binary(Mocha test)

I’m very new to Travis CI and I’m currently setting up a test for a Private project. I am facing an issue with the chrome. My automation framework is following a POM modal using nodejs, selenium-webdriver, and mocha.
Every time I trigger a new build my test fail in before hook as shown below :

 $ mocha tests/smokeSuite.js

  Smoke Suite: Chrome
    1) "before all" hook: ret for "Verify that User is able to Sign in with the existing Email Team credentials."
    2) "after all" hook: ret for "Verify that user is able to sign out of the account."

  0 passing (490ms)
  2 failing

  1) Smoke Suite: Chrome
       "before all" hook: ret for "Verify that User is able to Sign in the existing Email Team credentials.":
     WebDriverError: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429}),platform=Windows NT 10.0.17763 x86_64)
      at Object.checkLegacyResponse (node_modules\selenium-webdriver\lib\error.js:546:15)
      at parseHttpResponse (node_modules\selenium-webdriver\lib\http.js:509:13)

I have configured .travis.yml according to project requirement :

        language: node_js
        node_js: 
          - node
        os: windows
        addons:
         chrome: stable
        install: 
         - npm install
        jobs:
         include:
          - stage: "Tests 1"
            name: "Smoke Suite"
            script:
            - mocha tests/smokeSuite.js
          - os: windows
            language: node_js
            node_js:
             - node
            name: "Regression Suite"
            script: 
            - mocha tests --fgrep Regression

If anyone knows a solution, advice would be very much appreciated.
Thanks!

@native-api thanks for your response! I tried this solution but, not worked for me, or Might be I’m doing something wrong.
Can you explain where I need to add these lines of code? I tried it by adding in the .travis.yml file but after that same error is displayed to me.
If possible can you explain how to add it in .travis.yml or you can simply give me an updated version of travis.yml file that I added above in the topic content.
Thanks in advance!

I’m adding this as given below :

language: node_js
node_js: 
  - node
os: windows
before_install:
 if [[ $TRAVIS_OS_NAME == "windows" ]]; then
    echo Installing Google Chrome Stable...
    choco install googlechrome --acceptlicense --yes --no-progress --ignore-checksums
 fi
install: 
 - npm install
jobs:
 include:
  - stage: "Tests"
    name: "Smoke Suite"
    script:
    - mocha tests/smokeSuite.js
  - os: windows
    language: node_js
    name: "Regression Suite"
    script: 
    - mocha tests --fgrep Regression
before_install:
 if [[ $TRAVIS_OS_NAME == "windows" ]]; then

This is invalid YAML. A multiline command should be inserted as a YAML literal block:

before_install:
- |
  if [[ $TRAVIS_OS_NAME == "windows" ]]; then
    echo Installing Google Chrome Stable...
    choco install googlechrome --acceptlicense --yes --no-progress --ignore-checksums
  fi

Use https://config.travis-ci.com/explore to check whether your .travis.yml can be parsed and what it is parsed into.

1 Like

@native-api Thank you so much! Now it’s working fine for me with the help of this