컴퓨터/Python

selenium 팝업창 모두 닫기

풍경소리^^ 2021. 2. 14. 22:44

jeffrey-oh.tistory.com/268

# 팝업창 있으면 닫아라
handles = driver.window_handles
size = len(handles)
main_handle = driver.current_window_handle
for x in range(size):
    if handles[x] != main_handle:
        driver.switch_to.window(handles[x])
        driver.close()
driver.switch_to.window(main_handle)

 

저작자표시 비영리 변경금지 (새창열림)