Seleniumでログインが必要なサイトなどで
find_element_by_に関連したエラーがでます。
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'
原因はseleniumのバージョンが4.3.0 からでfind_element_by_の使い方が変わったからです
finf_element_by_name 4.3.0より前
find_element(By.ID, "xxx") 4.3.0以降
Byをimportして使用します
from selenium.webdriver.common.by import By
対応策
Seleniumのバージョンを下げる。これも解決策
# Seleniumのバージョンを下げる
$ pip install selenium==4.0.0
selenium 4.3.0以降の解決方法
入力フォームなどの要素を確認して下さい。Google ColaboratoryでもWorkします。
# Selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
ID = "yourID"
password = "yourpassword"
#ログイン情報入力
id = driver.find_element(By.ID, "user_session_email")
id.send_keys(ID)
#パスワード入力
password_input = driver.find_element(By.ID, "user_session_password")
password_input.send_keys(password)
#ログイン、クリック
login = driver.find_element(By.CSS_SELECTOR, "input.fade.commit")
login.click()