04-30 09:16
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- systemd
- Binary Search
- descriptive statistics
- Inheritance
- Operator
- Physical Scheme
- X.org
- 자바
- X윈도우
- spring
- Unity
- BFS
- 셀레니움
- preprocessing
- OOP
- 리눅스
- dbms
- python
- literal
- Entity Set
- 백준
- Polymolphism
- Reference Type
- 리눅스 마스터 1급
- External Scheme
- Class
- Mac
- Java
- selenium
- Entity
Archives
- Today
- Total
Byeol Lo
셀레니움에서 로딩 기다리기 본문
다음 함수를 가져와서 쓰면 된다.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selelnium import webdriver
url = 'https://www.naver.com/'
options = webdriver.ChromeOptions()
options.add_argument("headless")
driver = webdriver.Chrome(options=options)
driver.get(url)
WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.XPATH, value='XPATH 경로'))
)
WebDriverWait라는 함수는 driver에게 expected_conditions의 presence_of_element_located라는 옵션에서 튜플로 BY객체에서 해당 html 지정자가 어떤 형태인지 알려주는 것을 가져오고 value로 그에 맞는 경로를 입력해주면 된다.
위의 코드는 드라이버에게 해당 경로가 로딩되기까지 20초의 시간을 기다리게 하라는 명령어다. 20초가 지나도 해당 지정자가 활성화(?)되지 않으면 오류를 발생시킨다.
'Programming Language > Python' 카테고리의 다른 글
operator 모듈의 itemgetter, attrgetter 사용하기 (0) | 2022.06.16 |
---|---|
Numpy 라이브러리 사용 (0) | 2022.06.15 |
셀레니움 로그 남기지 않기 (0) | 2022.06.04 |
셀레니움 구글 드라이버 간편 설치 및 실행 (0) | 2022.06.04 |
구글 코랩에서 셀레니움 이용하기 (4) | 2022.06.04 |
Comments