-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
selenium 에서 웹드라이버를 불러오지 못하는 오류납니다~
23.09.24 18:32 작성 조회수 4.38k
0
Microsoft Windows [Version 10.0.19045.3448]
(c) Microsoft Corporation. All rights reserved.
C:\Users\user\data>C:/Users/user/AppData/Local/Programs/Python/Python311/python.exe c:/Users/user/data/sel.py
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path
path = SeleniumManager().driver_location(options) if path is None else path
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 76, in driver_location
browser = options.capabilities["browserName"]
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\user\data\sel.py", line 33, in <module>
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in init super().__init__(
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 51, in init
self.service.path = DriverFinder.get_path(self.service, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 40, in get_path
msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
^^^^^^^^^^^^^^^^^^^^
답변을 작성해보세요.
0
오유라
질문자2023.09.25
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
import sys
sys.executable
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
# 불필요한 에러 메시지 없애기
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
# 브라우저 생성
browser = webdriver.Chrome('C:/Users/user/Downloads/data/chromedriver.exe')
browser = webdriver.Chrome(options=chrome_options)
browser.get('https://www.naver.com')
browser.implicitly_wait(10)
browser.find_element_by_css_selector('a.nav.shop').click()
time.sleep(2)
search = browser.find_element_by_css_selector('input._searchInput_search_text_3CUDs')
search.click()
# 새창을 바라보게 만들기
new_window = browser.window_handles[1]
browser.switch_to.window(new_window)
# 화면 최대화 해야지 검색창이 보임
browser.maximize_window()
스타트코딩
지식공유자2023.09.27
강의를 찍은 시점에서 셀레니움이 조금 업데이트가 있었는데요
아래와 같은 방법으로 크롬 브라우저를 띄워주시면 됩니다.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
# 불필요한 에러 메시지 없애기
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
# 브라우저 생성
browser = webdriver.Chrome(options=chrome_options)
browser.get('https://www.naver.com')
그리고 (BONUS) 셀레니움 ver 4.0 가이드 + 크롬 드라이버 자동으로 다운 받는 법
영상 시청 후 find_element, find_elements 명령어 사용방법을 학습해 보시기 바랍니다 :)
답변 1