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[34], 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…

エラーの内容から見ると、options が文字列型 (str) であることが原因のようです。これは意図しない動作であり、おそらく何かしらの問題が発生している可能性があります。

以下のコードを試して、エラーが解消するかどうか確認してみてください:

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

このコードでは、webdriver_manager を使用して ChromeDriver をダウンロードしています。ChromeDriverManager().install() を呼び出すことで、最新の ChromeDriver を取得できます。おそらく、この方法で問題が解消されるかもしれません。

もしまだエラーが続く場合は、詳細な情報を提供していただけると助かります。それには、具体的なエラーメッセージや発生しているコードブロックなどが含まれます。

未分類

Posted by ぼっち