옵션체크 오류 정정

This commit is contained in:
R5600U_PC 2024-10-29 14:51:05 +09:00
parent a4717685a5
commit 385611b1bc
1 changed files with 36 additions and 1 deletions

View File

@ -619,6 +619,41 @@ class OptionHandler:
except Exception as e:
self.logger.error(f"옵션 필터링 및 조정 중 오류 발생: {e}", exc_info=True)
async def adjust_options_ori(self, filtered_option_names, max_option_count):
"""
필터링된 옵션에 맞게 체크박스 상태를 조정하는 메서드.
:param filtered_options: 필터링된 옵션 리스트
:param max_option_count: 최대 선택 가능한 옵션
"""
try:
# 옵션 체크 상태를 수집한 정보에서 필터링된 옵션들만 체크 상태로 유지
for i, name in enumerate(self.option_info['original_names'].values()):
checkbox_selector = self.checkbox_selector_template.format(index=i+1)
checkbox_element = await self.page.query_selector(checkbox_selector)
# is_checked = self.option_info['checked_states'].get(name, False)
# 디버깅 로그: 현재 옵션 이름과 필터링된 옵션 이름 확인
self.logger.debug(f"옵션 이름: {name}, 필터링된 옵션에 포함 여부: {name in filtered_option_names}")
if checkbox_element:
# 필터링된 이름에 포함되는 경우
if name in filtered_option_names:
# await checkbox_element.click()
self.logger.debug(f"옵션 '{name}' 체크함")
self.option_info['checked_states'][name] = True
# 필터링된 이름에 포함되지 않는 경우
else:
await checkbox_element.click()
self.logger.debug(f"옵션 '{name}' 체크 해제함")
self.option_info['checked_states'][name] = False
self.logger.debug(f"옵션 체크 상태 조정 완료.")
except Exception as e:
self.logger.error(f"옵션 체크 상태 조정 중 오류 발생: {e}", exc_info=True)
async def adjust_options(self, filtered_option_names, max_option_count):
"""
필터링된 옵션에 맞게 체크박스 상태를 조정하는 메서드.
@ -642,7 +677,7 @@ class OptionHandler:
if checkbox_element:
# 필터링된 옵션에 포함되고, 선택 가능한 수량 내라면 선택
if name in filtered_option_names and (max_option_count == 0 or selected_count < max_option_count):
await checkbox_element.click()
# await checkbox_element.click()
self.logger.debug(f"옵션 '{name}' 체크함")
self.option_info['checked_states'][name] = True
selected_count += 1