공부👻

no such element: Unable to locate element

당근먹는하니 2023. 1. 6. 11:14
728x90
반응형

파이썬 셀레니움 오류

 

no such element: Unable to locate element: {"method":"css selector","selector":"body > div > div.workseditor-content"

# 내용 입력하기
iframe = driver.find_element(By.CSS_SELECTOR,'#content > div.contents_area > div > div.editor_area > div > div.editor_body > iframe')
driver.switch_to.frame(iframe)
driver.find_element(By.CSS_SELECTOR, 'body > div > div.workseditor-content').click()
pyperclip.copy("오늘은 1월 6일 금요일이야.")
with pyautogui.hold(['command']):
    time.sleep(1)
    pyautogui.press('v')

iframe 때문에 그렇다고 한다. 

그래서 iframe에 포커스를 맞추고 찾으면 잘 찾아진다. (switch_to.frame()사용)

 

 

https://june98.tistory.com/98

 

728x90
반응형