Skip to content

Instantly share code, notes, and snippets.

@stoshiya
Last active June 7, 2019 07:14
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save stoshiya/3dc36187ede3e6eee3e4 to your computer and use it in GitHub Desktop.
Save stoshiya/3dc36187ede3e6eee3e4 to your computer and use it in GitHub Desktop.
MacでSeleniumをつかってChromeを起動するまで

MacでSeleniumをつかってChromeを起動するまで

必要なもの

  • Mac OS X
  • Google Chrome
  • Homebrew
  • Node.js
  • selenium-server-standalone
  • chromedriver

selenium-server-standalone と chromedriver をインストール

$ brew update
$ brew install selenium-server-standalone
$ brew install chromedriver

サーバ起動

$ /usr/local/bin/selenium-server -Dwebdriver.chrome.bin="/Applications/Google Chrome.app" -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver

テスト実行

$ mkdir selenium-chrome-test
$ cd selenium-chrome-test
$ npm install webdriverjs
$ node test-chrome.js
var webdriverjs = require('webdriverjs'),
client = webdriverjs.remote({
desiredCapabilities: {
browserName: 'chrome'
},
host: '127.0.0.1',
port: 4444,
logLevel: 'trace',
}).init();
client
.url('http://www.google.com')
.pause(2000)
.getTitle(function(err,title) {
console.log(title);
})
.end();
@vochicong
Copy link

brew services start chromedriver で chromedriver をバックグラウンドサービスとして動かすか、
使うたびに chromedriver を起動する必要があります。

@aristotll
Copy link

brew cask install chromedriver

No available formula with the name "chromedriver"
It was migrated from homebrew/core to caskroom/cask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment