AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'
Selenium(파이썬) 사용 시 위와 같은 에러가 발생했을 때 해결하는 방법입니다.
# 임포팅
from selenium.webdriver.common.by import By
# 기존 코드
driver.find_element_by_id("id_value")
# 수정 코드
driver.find_element(By.ID, "id_value")
기존 코드를 수정 코드와 같이 변경해주시면 됩니다.
driver.find_element_by_id("id_value")
driver.find_element(By.ID, "id_value")
[플그래밍/파이써언] - [파이썬] Selenium - 모든 쿠키 추출하기
[파이썬] Selenium - 모든 쿠키 추출하기
Selenium으로 접속한 사이트의 모든 쿠키를 추출하는 기능입니다. from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.naver.com") # 모든 쿠기 추출 cookies = driver.get_cookies() print("All Cookies:",
hoood.tistory.com
[플그래밍/파이써언] - [파이썬] Selenium - 자바스크립트로 스타일(css) 변경하기
[파이썬] Selenium - 자바스크립트로 스타일(css) 변경하기
Selenium으로 사이트를 연 후 특정 요소의 스타일을 변경하는 방법입니다. from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options chrome_options = Options() chro
hoood.tistory.com
[플그래밍/파이써언] - [파이썬] Selenium - 여러 탭 열기 및 이동하는 방법
[파이썬] Selenium - 여러 탭 열기 및 이동하는 방법
Selenium으로 세 개의 사이트를 연 후 탭 이동하는 방법입니다. from selenium import webdriver import time driver = webdriver.Chrome() # 첫 번째 탭 열기 driver.get("http://www.daum.net") time.sleep(1) # 1초 대기 # 두 번째 탭
hoood.tistory.com
[플그래밍/파이써언] - [파이썬] Selenium - 헤드레스(Headless, 창 없는 백그라운드 실행) 모드
[파이썬] Selenium - 헤드레스(Headless, 창 없는 백그라운드 실행) 모드
헤드레스 모드란 창을 띄우지 않고 Selenium을 실행하는 기능입니다. from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') driver = webdriver.Chrome(o
hoood.tistory.com
[플그래밍/파이써언] - [파이썬] Selenium - 마우스 우클릭 (ActionChains)
[파이썬] Selenium - 마우스 우클릭 (ActionChains)
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome() driver.get("https://www.naver.com") elem
hoood.tistory.com
'플그래밍 > 파이써언' 카테고리의 다른 글
selenium value 값 가져오기 (2) | 2024.11.18 |
---|---|
[파이썬] Selenium - HTTP Error 404: Not Found (829) | 2024.05.01 |
[파이썬] Selenium - 모든 쿠키 추출하기 (48) | 2024.04.24 |
[파이썬] Selenium - 자바스크립트로 스타일(css) 변경하기 (52) | 2024.04.24 |
[파이썬] Selenium - 여러 탭 열기 및 이동하는 방법 (31) | 2024.04.24 |