12
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Selenium NameError: name 'By' is not defined

Last updated at Posted at 2022-07-08

この記事のとおり実行した場合も

selenium.py
serch_box = driver.find_element(By.NAME, 'q')
serch_button = driver.find_element(By.NAME,"btnK")
NameError: name 'By' is not defined

このように出てしまいます。
その場合

from selenium.webdriver.common.by import By

をインポートすることで解決します。

参考
https://stackoverflow.com/questions/44629970/python-selenium-webdriver-name-by-not-defined

12
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?