diff --git a/fastfive-auto-app-dev/pages/reservation_page.py b/fastfive-auto-app-dev/pages/reservation_page.py index 8a352dd..dde359a 100644 --- a/fastfive-auto-app-dev/pages/reservation_page.py +++ b/fastfive-auto-app-dev/pages/reservation_page.py @@ -10,7 +10,7 @@ class ReservationPage(BasePage): # Android 선택자 ANDROID = { - 'reservation_tab': (By.XPATH, '//android.view.View[@content-desc="예약"]'), + 'reservation_tab': (By.XPATH, '//*[@content-desc="예약" or @text="예약"]'), 'meeting_room': (By.XPATH, '//android.widget.TextView[@text="미팅룸"]'), 'time_slots': (By.XPATH, '//android.widget.TextView[contains(@text, ":00")]'), 'credit_text': (By.XPATH, '//android.widget.TextView[contains(@text, "크레딧")]'), @@ -26,7 +26,7 @@ class ReservationPage(BasePage): IOS = { 'reservation_tab': (By.XPATH, '//XCUIElementTypeButton[contains(@label, "예약")]'), 'meeting_room': (By.XPATH, '//*[@name="미팅룸" or @label="미팅룸"]'), - 'room_card': (By.XPATH, '//XCUIElementTypeScrollView//XCUIElementTypeOther[contains(@name, "L") and contains(@name, "층")]'), + 'room_card': (By.XPATH, '//XCUIElementTypeScrollView//XCUIElementTypeCell | //XCUIElementTypeScrollView//XCUIElementTypeOther[.//*[contains(@name, "층") or contains(@value, "층")]]'), 'time_slots': (By.XPATH, '//XCUIElementTypeOther[contains(@name, ":00") or contains(@name, ":30")]'), 'credit_text': (By.XPATH, '//*[contains(@name, "크레딧") or contains(@label, "크레딧")]'), 'required_checkbox': (By.XPATH, '//*[contains(@name, "필수") or contains(@label, "필수")]'), @@ -77,38 +77,41 @@ def _find_available_time_slot_ios(self): if not room_cards: print("방 카드를 찾지 못함 - 좌표 기반 탭 시도") window_size = self.driver.get_window_size() - tap_x = window_size['width'] // 2 - tap_y = int(window_size['height'] * 0.35) + self.tap(window_size['width'] // 2, int(window_size['height'] * 0.35)) print(f"방 카드 탭 (x={tap_x}, y={tap_y})") - self.tap(tap_x, tap_y) self.wait_seconds(2) else: room_cards[0].click() print("첫번째 방 카드 클릭") - self.wait_seconds(1) + self.wait_seconds(2) window_size = self.driver.get_window_size() - current_hour = datetime.now().hour + next_hour = current_hour + 1 - # 다양한 x 좌표로 타임라인 탭 시도 (주황색 예약된 시간 피하기) - timeline_y = int(window_size['height'] * 0.62) - # 화면 왼쪽부터 오른쪽까지 여러 위치 시도 - x_ratios = [0.2, 0.35, 0.5, 0.65, 0.8] - - for x_ratio in x_ratios: - tap_x = int(window_size['width'] * x_ratio) - print(f"타임라인 탭 (x={tap_x}, y={timeline_y})") - self.tap(tap_x, timeline_y) - self.wait_seconds(0.8) - - # 크레딧 확인 - valid_credit = self._check_credit_ios() - if valid_credit and valid_credit > 0: - selected_time = self._get_selected_time_ios() - print(f"예약 가능한 시간대 발견: {selected_time} ({valid_credit}크레딧)") - return selected_time, valid_credit - else: - print(f"x={tap_x}: 크레딧 없음 - 다음 위치 시도") + # 다음 시간 레이블(예: "23:00") 위치로 탭 좌표 계산 + try: + label = self.driver.find_element( + By.XPATH, f'//*[@name="{next_hour}:00" or @label="{next_hour}:00"]' + ) + loc = label.location + tap_x = max(loc['x'] - 30, 10) + tap_y = loc['y'] + print(f"{next_hour}:00 레이블 기반 탭 (x={tap_x}, y={tap_y})") + except Exception: + # 스크린샷 분석 기준: 타임라인 y≈59%, 23시는 x≈87% + tap_x = int(window_size['width'] * 0.87) + tap_y = int(window_size['height'] * 0.59) + print(f"고정 좌표 탭 (x={tap_x}, y={tap_y})") + + self.tap(tap_x, tap_y) + self.wait_seconds(1) + + # 크레딧 확인 + valid_credit = self._check_credit_ios() + if valid_credit and valid_credit > 0: + selected_time = self._get_selected_time_ios() + print(f"예약 가능한 시간대 발견: {selected_time} ({valid_credit}크레딧)") + return selected_time, valid_credit return None, None