CentOS Google-Chrome chromedriver-binary インストールメモ

## Linux に Chrome をインストールしてseleniumで遊ぶメモ

### Chrome インストール
初期設定では認識しないのでrepo用ファイルを作成

```
# vi /etc/yum.repos.d/google.chrome.repo
```

ファイル内容

```
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
```

確認

```
# yum search google chrome
google-chrome                                                                                                                   13 kB/s | 3.5 kB     00:00    
============================================================== 名前 & 概要 一致: google, chrome ===============================================================
google-chrome-beta.x86_64 : Google Chrome (beta)
google-chrome-stable.x86_64 : Google Chrome
google-chrome-unstable.x86_64 : Google Chrome (unstable)
============================================================== 概要 & 名前 一致: google, chrome ===============================================================
chrome-remote-desktop.x86_64 : Remote desktop support for google-chrome & chromium
chromedriver.x86_64 : WebDriver for Google Chrome/Chromium
```

インストール

```
# yum install google-chrome-stable -y

google-chrome-stable-101.0.4951.41-1.x86_64
完了しました!
```

selenium インストール

```
# pip install selenium
```

ドライバインストール

```
# pip install chromedriver-binary==101.0.4951.41
```

バージョンがないと怒られる

```
Collecting chromedriver-binary==101.0.4951.41
  Could not find a version that satisfies the requirement chromedriver-binary==101.0.4951.41 (from versions: 2.29.1, 2.31.1, 2.33.1, 2.34.0, 2.35.0, 2.35.1, 2.36.0, 2.37.0, 2.38.0, 2.39.0, 2.40.1, 2.41.0, 2.42.0, 2.43.0, 2.44.0, 2.45.0, 2.46.0, 70.0.3538.16.0, 70.0.3538.67.0, 70.0.3538.97.0, 71.0.3578.30.0, 71.0.3578.33.0, 71.0.3578.80.0, 71.0.3578.137.0, 72.0.3626.7.0, 72.0.3626.69.0, 73.0.3683.20.0, 73.0.3683.68.0, 74.0.3729.6.0, 75.0.3770.8.0, 75.0.3770.90.0, 75.0.3770.140.0, 76.0.3809.12.0, 76.0.3809.25.0, 76.0.3809.68.0, 76.0.3809.126.0, 77.0.3865.10.0, 77.0.3865.40.0, 78.0.3904.11.0, 78.0.3904.70.0, 78.0.3904.105.0, 79.0.3945.16.0, 79.0.3945.36.0, 80.0.3987.16.0, 80.0.3987.106.0, 81.0.4044.20.0, 81.0.4044.69.0, 81.0.4044.138.0, 83.0.4103.14.0, 83.0.4103.39.0, 84.0.4147.30.0, 85.0.4183.38.0, 85.0.4183.83.0, 85.0.4183.87.0, 86.0.4240.22.0, 87.0.4280.20.0, 87.0.4280.87.0, 87.0.4280.88.0, 88.0.4324.27.0, 88.0.4324.27.1, 88.0.4324.96.0, 89.0.4389.23.0, 90.0.4430.24.0, 91.0.4472.19.0, 91.0.4472.101.0, 92.0.4515.43.0, 92.0.4515.107.0, 93.0.4577.15.0, 93.0.4577.63.0, 94.0.4606.41.0, 94.0.4606.61.0, 94.0.4606.113.0, 95.0.4638.10.0, 95.0.4638.17.0, 95.0.4638.54.0, 95.0.4638.69.0, 96.0.4664.18.0, 96.0.4664.35.0, 96.0.4664.45.0, 97.0.4692.20.0, 97.0.4692.36.0, 97.0.4692.71.0, 98.0.4758.48.0, 98.0.4758.80.0, 98.0.4758.102.0, 99.0.4844.17.0, 99.0.4844.35.0, 99.0.4844.51.0, 100.0.4896.20.0, 100.0.4896.60.0, 101.0.4951.15.0)
No matching distribution found for chromedriver-binary==101.0.4951.41
```

最も近いバージョンをインストールする

```
# pip install chromedriver-binary==101.0.4951.15.0
Collecting chromedriver-binary==101.0.4951.15.0
  Downloading https://files.pythonhosted.org/packages/7d/6a/d7d079cd612dc9f76ae32d7afe2d439a83fcf086cee93ee24f29b8d98271/chromedriver-binary-101.0.4951.15.0.tar.gz
Installing collected packages: chromedriver-binary
  Running setup.py install for chromedriver-binary ... done
Successfully installed chromedriver-binary-101.0.4951.15.0
```

AttributeError: 'WebDriver' object has no attribute 'find_element_by_name'

pip install selenium==4.1.0