from selenium.common.exceptions import NoSuchWindowException
from selenium.webdriver.support.ui import WebDriverWait
def found_window(name):
def predicate(driver):
try: driver.switch_to_window(name)
except NoSuchWindowException:
return False
else:
return True # found window
return predicate
driver.find_element_by_id("id of the button that opens new window").click()
WebDriverWait(driver, timeout=50).until(found_window("new window name"))
WebDriverWait(driver, timeout=10).until( # wait until the button is available
lambda x: x.find_element_by_id("id of button present on newly opened window"))\
.click()
'Python > Web crowling' 카테고리의 다른 글
selenium 새 창 로딩될 때까지 기다리기 (0) | 2020.02.10 |
---|---|
Selenium에서의 병렬 실행 및 세션 처리 (0) | 2020.02.09 |
[ selenium의 webdriver() / implicitly_wait() / WebDriverWait() + EC + By ==> bs4 ]를 이용한 연결된 페이지를 타고가서/기다렸다가 추가정보를 scrapping하는 crawling (0) | 2020.02.09 |
window,mac selenium 새 탭 열기 및 탭 전환 (0) | 2020.02.09 |
열려있는 chrome에서 크롤링 (4) | 2020.02.09 |