가장 일반적으로 사용되는 시나리오 :
- 새 창에서 페이지 열기
 - 그것으로 전환
 - 뭔가해라.
 - 닫아
 - 부모 창으로 다시 전환
 
# Open "Google" page in parent window
driver.get("https://google.com")
driver.title # 'Google'
# Get parent window
parent_window = driver.current_window_handle 
# Open "Bing" page in child window
driver.execute_script("window.open('https://bing.com')") 
# Get list of all windows currently opened (parent + child)
all_windows = driver.window_handles 
# Get child window
child_window = [window for window in all_windows if window != parent_window][0] 
# Switch to child window
driver.switch_to.window(child_window) 
driver.title # 'Bing'
# Close child window
driver.close() 
# Switch back to parent window
driver.switch_to.window(parent_window) 
driver.title # 'Google'
'Python > Web crowling' 카테고리의 다른 글
| window,mac selenium 새 탭 열기 및 탭 전환 (0) | 2020.02.09 | 
|---|---|
| 열려있는 chrome에서 크롤링 (4) | 2020.02.09 | 
| selenium으로 크롤링 시 현재 실행중인 크롬에서 실행하기 (0) | 2020.02.09 | 
| 웹 크롤러 - 봇 탐지 우회하기 (1) | 2020.02.09 | 
| 창없는 크롬으로 크롤링하기 (0) | 2020.02.09 |