반응형

셀레니움, 페이지 로딩 기다리기 (특정 조건)

 

글. 수알치 오상문 

 

element_to_be_clickable처럼 기다리는 조건에 다음처럼 다양하게 지정할 수 있다.

 

EC.title_is(...)
EC.title_contains(...)
EC.presence_of_element_located(...)
EC.visibility_of_element_located(...)
EC.visibility_of(...)
EC.presence_of_all_elements_located(...)
EC.text_to_be_present_in_element(...)
EC.text_to_be_present_in_element_value(...)
EC.frame_to_be_available_and_switch_to_it(...)
EC.invisibility_of_element_located(...)
EC.element_to_be_clickable(...)
EC.staleness_of(...)
EC.element_to_be_selected(...)
EC.element_located_to_be_selected(...)
EC.element_selection_state_to_be(...)
EC.element_located_selection_state_to_be(...)
EC.alert_is_present(...)

 

# 페이지 로딩 테스트
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.implicitly_wait(10) # seconds
driver.get("http://daum.net")
# 로딩 기다리기 
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'wrapSearch')))
print("OK")
input("Quit?: ")
driver.quit()

 

 

반응형

+ Recent posts