퇴근 후 코딩/에러 모음
stale element reference: element is not attached to the page document
통계적자유
2023. 4. 2. 23:40
셀레니움으로 웹크롤링 코드를 짤 때 아래와 같은 에러가 뜨는 이유는 화면이 바뀔 시간이 부족한것이 원인이므로,
StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
time.sleep(1) 으로 쉬는 시간을 주면 해결된다.
같은 에러가 지속 반복된다면, 쉬는 시간을 더 늘려보자.
price_ascending=browser.find_element(By.CSS_SELECTOR,'.list_fixed>div.sorting>a.sorting_type.is-descending')
## 쉬는 시간 부여
time.sleep(1)
price_ascending.click()
쉬는 시간은 소중해.