Can I start a Selenium server inside Travis?

I want to run the full Selenium test in Travis, but I seem to be unable to start the server.

My Travis YAML file

language: node_js

node_js:
  - "6.2"

before_script:
  - npm install selenium-standalone@latest -g
  - selenium-standalone install
  - npm install -g gulp
  - nohup selenium-standalone start > selenium.txt 2>&1 </dev/null &

script:
  - npm test
  - gulp

When executed npm test, the result:

Error retrieving a new session from the selenium server
Error: connect ECONNREFUSED 127.0.0.1:4444
    at Object.exports._errnoException (util.js:1007:11)
    at exports._exceptionWithHostPort (util.js:1030:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
Connection refused! Is selenium server started?
npm ERR! Test failed.  See above for more details.
+4
source share
1 answer

It! I just did.

Here are my dependencies package.json:

"wdio-mocha-framework": "^0.5.10",
"wdio-selenium-standalone-service": "0.0.9",
"wdio-spec-reporter": "^0.1.0",
"webdriverio": "^4.8.0"

Here is my .travis.ymlfile:

sudo: required  
dist: trusty 
language: node_js
node_js:
  - "4.4"
env:
  global:
    - CXX=g++-4.8
    - DISPLAY=:99.0
    - CHROME_BIN=/usr/bin/google-chrome
addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8      
before_script:
  - "sh -e /etc/init.d/xvfb start"
  - sleep 3 # give xvfb some time to start
  - sudo apt-get update
  - sudo apt-get install -y libappindicator1 fonts-liberation
  - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  - sudo dpkg -i google-chrome*.deb
  - npm install --dev
  - npm run run & # to run my web server in the background
  - sleep 5 # give web server some time to start

And here is an excerpt of my file wdio.conf.js:

exports.config = {
    capabilities: [{
        maxInstances: 1,
        browserName: 'chrome'
    }],
    services: ['selenium-standalone'],
    framework: 'mocha',
    reporters: ['spec'],
    mochaOpts: {
        ui: 'bdd'
    },
}
0
source

All Articles