from selenium import webdriver
from selenium.webdriver.support.ui import Select
# 웹드라이버 초기화 (크롬 드라이버 예제)
driver = webdriver.Chrome()
# 웹페이지 열기
driver.get("https://example.com") # 대상 웹페이지 주소로 변경
# 콤보박스 식별 (XPath를 사용하는 예제)
combo_box = driver.find_element_by_xpath("//select[@id='yourComboBoxId']") # 대상 콤보박스의 id 속성으로 변경
# 셀렉트 객체 생성
select = Select(combo_box)
# 콤보박스의 모든 옵션 텍스트 가져오기
all_options = select.options
# 각 옵션의 텍스트 출력
for option in all_options:
print(option.text)
# 웹드라이버 종료
driver.quit()
'컴퓨터 > Python' 카테고리의 다른 글
python 사용자 Downloads 폴더에 생성일자 오늘인 파일 출력하기 (0) | 2023.12.13 |
---|---|
flask 액세스 권한에 의해 숨겨진 소켓에 액세스를 시도했습니다 (0) | 2023.12.07 |
python pyside6 그림 이미지 순환 (0) | 2023.12.02 |
python messagebox pyside6 pyqt5 (0) | 2023.11.27 |
윈도우 핸들 활성화 focus, window detective 프로그램 (0) | 2023.11.21 |