TROUBLESHOOTING
selenium AttributeError 'Webdriver' object has no attribute 'find_element_by_id'
thovy
2022. 7. 8. 20:18
728x90
반응형
SMALL
셀레니움 업데이트로 문법이 바뀌었다.
일주일 전에 문제가 생겼다.
❌ TROUBLE
selenium AttributeError 'Webdriver' object has no attribute 'find_element_by_id'
find_elements_by_tag_name 등
찾아보니 find by 문법이 바뀌었다.
이미지의 맨 아래와 같은 문법 find\_element\_by\_tag\_name()
으로 사용하면
AttributeError
'WebDriver' object has no attribute 'find\_element\_by\_tag\_name'
이라는 에러가 나온다.
왜냐면
selenium이 업데이트 되면서
find_element_by_@@@( " ### " )
, find_elements_by_@@@( " ### " )
같은 문법이 사라졌기 때문!
✅ 해결법
`find_element( " @@@ " , " ### " ) 라는 형태로 바뀜
이미지 맨 위 처럼. find_element( " id " , " query " ) 라고 사용한다.
이미지 맨 아래의 예전 문법을 고쳐보면
find_element_by_tag_name("a") → find_element("tag_name", "a")
라고 하면 된다.
아무튼 결론은 "업데이트로 문법이 바뀌었다"
참고 : stackoverflow
728x90
반응형
LIST