본문 바로가기
● 크롤링, 자동화/Selenium

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".p"} (Session info: chrome=90.0.4430.212)

by 0ver-grow 2021. 5. 19.
반응형

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".p"} (Session info: chrome=90.0.4430.212)

 

원인 : 페이지 로드시 .p가 생성되지 않으므로 NoSuchElementException에러가 발생

해결법 : 셀레니움의 대기(Waits)기능을 이용해서 해결

 

p_tag = WebDriverWait(browser,timeout=5).until(EC.presence_of_element_located((By.TAG_NAME, "p")))

print("p태그를 찾았습니다.")

https://workingwithpython.com/selenium-waits/

 

셀레니움(Selenium)에서 대기(Waits)하기 - 크롤링을 위한 파이썬(Python)

파이썬으로 셀레니움 크롤링을 할 때 NoSuchElementException에러가 발생할 수 있습니다. 이러한 경우 셀레니움에서 접근하고자 하는 요소가 생성될 때까지 대기(Waits)하여 에러를 방지할 수 있습니다.

workingwithpython.com

 

반응형