スペルミスです
import selenium
from selenium.webdriver.common.by import By
- elem_pass = browser.find_element(BY.ID, 'inputPassword')
+ elem_pass = browser.find_element(By.ID, 'inputPassword')
Like!
pythonのJupiterNotebookでのseleniumでスクレイピングをするとエラーが出てしまいます。
DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
elem_pass = browser.find_element_by_id('inputPassword')
次の記事を参考にしてターミナルでseleniumのヴァージョンを4.3.0から4.1.0に変更しました。
それでもエラーが出たので、次の記事を参考にして次のようにコードを書き換えました。
import selenium
from selenium.webdriver.common.by import By
elem_pass = browser.find_element(BY.ID, 'inputPassword')
すると、BYが定義されていないというエラーが出てしまいました。
NameError: name 'BY' is not defined
どうすればエラーメッセージが出ずに処理できるでしょうか。
スペルミスです
import selenium
from selenium.webdriver.common.by import By
- elem_pass = browser.find_element(BY.ID, 'inputPassword')
+ elem_pass = browser.find_element(By.ID, 'inputPassword')