-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_알림창처리.py
More file actions
41 lines (27 loc) · 1.27 KB
/
4_알림창처리.py
File metadata and controls
41 lines (27 loc) · 1.27 KB
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
31
32
33
34
35
36
37
38
39
40
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.alert import Alert
import time # 시간 관련 함수를 사용하기 위해 time 모듈을 임포트
# 옵션 설정을 위해 option 객체 생성
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
options.add_argument("disable-blink-features=AutomationControlled") # 자동화 탐지 방지
options.add_experimental_option("excludeSwitches", ["enable-automation"]) # 자동화 표시 제거
options.add_experimental_option('useAutomationExtension', False) # 자동화 확장 기능 사용 안 함
# 옵션을 적용하여 드라이버 객체 생성
driver = webdriver.Chrome(options=options)
driver.get("http://www.naver.com")
time.sleep(2)
driver.execute_script("window.alert('창 열림')")
# 시스템 알림창 요소를 가져온다.
alert= driver.switch_to.alert # 창 열림
time.sleep(3
)
# 시스템 알림창을 확인한다.(OK 버튼)
alert.accept()
# 알림창 거부 (Cancel 버튼, Confirm 창에서만 가능)
# alert.dismiss()
# Prompt 창에 텍스트 입력
# alert.send_keys("입력할 텍스트")