提交 77b37e38 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

some vps run docker need chrome with args --no-sandbox?

上级 6ceeec58
......@@ -4,7 +4,7 @@
"description": "Wechat for Bot (Personal Account)",
"main": "index.js",
"wechaty": {
"DEFAULT_HEAD": "chrome",
"DEFAULT_HEAD": "phantomjs",
"DEFAULT_PUPPET": "web",
"DEFAULT_PORT": 8788,
"DEFAULT_PUPPET_PORT": 58788
......@@ -14,7 +14,7 @@
"pretest": "npm run lint",
"start": "node bin/io-bot",
"demo": "node example/ding-dong-bot.js",
"test": "cross-env LC_ALL=C TAP_TIMEOUT=600 WECHATY_LOG=silly tape \"test/**/*.spec.js\"",
"test": "cross-env LC_ALL=C TAP_TIMEOUT=600 tape \"test/**/*.spec.js\"",
"devtest": "cross-env LC_ALL=C TAP_TIMEOUT=600 tape"
},
"repository": {
......
......@@ -7,4 +7,4 @@
sudo apt-get install -y google-chrome-stable
}
google-chrome-stable --version
google-chrome --version
......@@ -83,10 +83,7 @@ class Browser extends EventEmitter {
.build()
break
case /chrome/i.test(this.head):
this.driver = new WebDriver.Builder()
.setAlertBehavior('ignore')
.forBrowser('chrome')
.build()
this.driver = this.getChromeDriver()
break
default: // unsupported browser head
throw new Error('unsupported head: ' + this.head)
......@@ -106,6 +103,17 @@ class Browser extends EventEmitter {
return this.driver.navigate().refresh()
}
getChromeDriver() {
const customChrome = WebDriver.Capabilities.chrome()
.set('webdriver.chrome.args', '--no-sandbox')
return new WebDriver.Builder()
.setAlertBehavior('ignore')
.forBrowser('chrome')
.withCapabilities(customChrome)
.build()
}
getPhantomJsDriver() {
// setup custom phantomJS capability https://github.com/SeleniumHQ/selenium/issues/2069
const phantomjsExe = require('phantomjs-prebuilt').path
......@@ -115,7 +123,8 @@ class Browser extends EventEmitter {
'--load-images=false'
, '--ignore-ssl-errors=true' // this help socket.io connect with localhost
, '--web-security=false' // https://github.com/ariya/phantomjs/issues/12440#issuecomment-52155299
, '--ssl-protocol=TLSv1' // https://github.com/ariya/phantomjs/issues/11239#issuecomment-42362211
//, '--ssl-protocol=TLSv1' // https://github.com/ariya/phantomjs/issues/11239#issuecomment-42362211
, '--ssl-protocol=any' // http://stackoverflow.com/a/26503588/1123955
// issue: Secure WebSocket(wss) do not work with Self Signed Certificate in PhantomJS #12
// , '--ssl-certificates-path=D:\\cygwin64\\home\\zixia\\git\\wechaty' // http://stackoverflow.com/a/32690349/1123955
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册