728x90
XPath나 ID값이 맞는데 selenium이 찾지 못하는 경우는
해당 html 태그가 iframe에 속해있는지를 확인해 주어야 한다.
찾으려는 태그가 iframe 안에 속해있었기 때문에 해당 에러를 발생했다.
해결 방법
driver.switch_to.frame(driver.find_element(By.ID, '~~frame'))
추가로, 이후에 다른 태그를 찾을 때 해당 태그가 다른 iframe에 속해있는지 확인해주고
해당 iframe이 아닌 다른 iframe으로 소속되어 있을 때는 아래의 코드로 초기화를 해준 다음 다음 태그를 찾으면 된다.
driver.switch_to.default_content()
728x90
'Python' 카테고리의 다른 글
python logging (로그파일 생성) (0) | 2022.08.19 |
---|---|
[pyautogui] click, keyDown, press not working, python 관리자 권한으로 실행 (0) | 2022.08.19 |
[selenium] cookie 설정 방법 (0) | 2022.08.19 |
[selenium] no such element: Unable to locate element (0) | 2022.08.19 |
[selenium] executable_path has been deprecated, please pass in a Service object (0) | 2022.08.19 |