是否可以在 Travis 中启动 Selenium 服务器? [英] Is it possible to start a Selenium server inside Travis?
本文介绍了是否可以在 Travis 中启动 Selenium 服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Travis 中运行一个完整的 Selenium 测试,但我似乎无法启动服务器.
I want to run a complete Selenium test within Travis, but I seem unable to get the server started.
我的 Travis YAML 文件
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
当npm test
运行时,结果为:
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.
推荐答案
就是这样!我刚做了.
这是我的 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"
这是我的 .travis.yml
文件:
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
这是我的 wdio.conf.js
文件的摘录:
And here's an extract of my wdio.conf.js
file:
exports.config = {
capabilities: [{
maxInstances: 1,
browserName: 'chrome'
}],
services: ['selenium-standalone'],
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd'
},
}
这篇关于是否可以在 Travis 中启动 Selenium 服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文