回答編集履歴
1
コメントに対する追記
answer
CHANGED
@@ -4,4 +4,37 @@
|
|
4
4
|
|
5
5
|
> Path to the Chrome executable to use (on Mac OS X, this should be the actual binary, not just the app. e.g., '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')
|
6
6
|
|
7
|
-
とありますが...
|
7
|
+
とありますが...
|
8
|
+
|
9
|
+
|
10
|
+
----
|
11
|
+
(2018-09-25 11:45追記)
|
12
|
+
|
13
|
+
ドキュメントを読んだ感じでは、パスの指定が必要かと思ったのですが、macOS で実際に試してみたらオプションでバイナリーパスを設定しなくても動作するようです。
|
14
|
+
|
15
|
+
Chrome が、`/Applications/Google Chrome.app` にあり `http://chromedriver.storage.googleapis.com/index.html?path=2.42/` からダウンロードした `chromedriver` を パスが通った場所にコピーしておいて、
|
16
|
+
|
17
|
+
```
|
18
|
+
require "selenium-webdriver"
|
19
|
+
|
20
|
+
driver = Selenium::WebDriver.for :chrome
|
21
|
+
driver.get("https://www.google.com")
|
22
|
+
puts driver.title
|
23
|
+
```
|
24
|
+
|
25
|
+
だけで問題なく動作して、ページタイトルが取れました。
|
26
|
+
|
27
|
+
|
28
|
+
また、コメントに書かれていたソースコードで、下記の Webdriver 部分だけを実行してみるとエラーは出ませんでしたので、環境構築の問題のように思えます。
|
29
|
+
|
30
|
+
```
|
31
|
+
require "selenium-webdriver"
|
32
|
+
|
33
|
+
driver = Selenium::WebDriver.for :chrome
|
34
|
+
driver.navigate.to 'https://www.justwatch.com/jp/検索?q=あああ'
|
35
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 300)
|
36
|
+
wait.until { driver.find_element(xpath: '//div[2]/filter-bar/div[2]/div[2]/div[3]/div[2]/div') }
|
37
|
+
```
|
38
|
+
|
39
|
+
`which chromedriver` で、 chromedriver は、見つかる場所にありますか?
|
40
|
+
まずは、簡単な動作からテストして、動くのを確認してから本来のプログラムを書く方が良いと思いますので、上記の"Google" のタイトルを取得するプログラムを動かしてみてください。
|