diff --git a/package.json b/package.json index cc66d5ad2b06d23b4105f71eeeb5f845b7125ed5..6bf9ec6b267852968042a4ad160fe41aa7eb3087 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/script/install-chrome-linux.sh b/script/install-chrome-linux.sh index 3eb19288a4a7bde6e11d55255d1fcf2dadfc4df9..c3459fe9704c75e519abe8fca50e0b91e86637c1 100755 --- a/script/install-chrome-linux.sh +++ b/script/install-chrome-linux.sh @@ -7,4 +7,4 @@ sudo apt-get install -y google-chrome-stable } -google-chrome-stable --version +google-chrome --version diff --git a/src/puppet-web/browser.js b/src/puppet-web/browser.js index 8099eb4c929918097158b3deb3a542980f3d785d..95d51a6ae35476a42f204b555aae2037e2910e66 100644 --- a/src/puppet-web/browser.js +++ b/src/puppet-web/browser.js @@ -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