————————————————————————— AttributeError Traceback (most recent call last) File ~/.local/lib/python3.8/site-packages/selenium/webdriver/common/driver_finder.py:38, in DriverFinder.get_path(service, options) 37 try: —> 38 path = SeleniumManager().driver_location(options) if path is None else path 39 except Exception as err: File ~/.local/lib/python3.8/site-packages/selenium/webdriver/common/selenium_manager.py:84, in SeleniumManager.driver_location(self, options) 77 “””Determines the path of the correct driver. 78 79 :Args: 80 – browser: which browser to get the driver path for. 81 :Returns: The driver path to use 82 “”” —> 84 browser = options.capabilities[“browserName”] 86 args = [str(self.get_binary()), “–browser”, browser] AttributeError: ‘str’ object has no attribute ‘capabilities’ During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) Cell In[36], line 5 2 from webdriver_manager.chrome import ChromeDriverManager 4 # ChromeDriverを起動 … —> 40 msg = f”Unable to obtain driver for {options.capabilities[‘browserName’]} using Selenium Manager.” 41 raise NoSuchDriverException(msg) from err 43 if path is None or not Path(path).is_file(): AttributeError: ‘str’ object has no attribute ‘capabilities’ Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings…

このエラーは、webdriver_manager ライブラリが ChromeDriver を取得する際に問題が発生している可能性があります。一般的に、webdriver_manager を使用する場合、以下のように webdriver.Chrome() を利用します。

python
from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager # ChromeDriverを起動 driver = webdriver.Chrome(ChromeDriverManager().install())

しかし、このエラーが発生していることから、何らかの問題が発生しています。以下の手順を試してみてください:

  1. webdriver_manager ライブラリを最新のバージョンにアップデートします。
bash
pip install --upgrade webdriver_manager
  1. もしもまだ発生する場合は、手動で ChromeDriver をダウンロードし、executable_path を指定してみてください。
python
from selenium import webdriver chrome_path = "/path/to/chromedriver" # ダウンロードした ChromeDriver のパスに置き換えてください driver = webdriver.Chrome(executable_path=chrome_path)

これらの手順で問題が解決しない場合は、エラーメッセージや追加のコードを提供いただければ、より具体的なサポートが可能です。

未分類

Posted by ぼっち