diff --git a/fastfive-auto-app-dev/pages/entrance_card_page.py b/fastfive-auto-app-dev/pages/entrance_card_page.py new file mode 100644 index 0000000..d2885a3 --- /dev/null +++ b/fastfive-auto-app-dev/pages/entrance_card_page.py @@ -0,0 +1,69 @@ +from selenium.webdriver.common.by import By +from .base_page import BasePage + + +class EntranceCardPage(BasePage): + ANDROID = { + 'entrance_tab': (By.XPATH, '//*[@content-desc="출입카드" or @text="출입카드"]'), + } + + IOS = { + 'entrance_tab': (By.XPATH, '//XCUIElementTypeButton[contains(@label, "출입카드")]'), + } + + def get_selector(self, key): + return self.ANDROID[key] if self.is_android() else self.IOS[key] + + def go_to_entrance_card_tab(self): + self.click(self.get_selector('entrance_tab')) + print("출입카드 탭 클릭") + self.wait_seconds(2) + + def long_press_card(self): + """검은 카드 영역 1초 롱프레스""" + window_size = self.driver.get_window_size() + tap_x = window_size['width'] // 2 + tap_y = int(window_size['height'] * 0.78) + print(f"카드 롱프레스 (x={tap_x}, y={tap_y}, 1초)") + + if self.is_android(): + self.driver.execute_script('mobile: longClickGesture', { + 'x': tap_x, 'y': tap_y, 'duration': 1000 + }) + else: + self.driver.execute_script('mobile: touchAndHold', { + 'x': tap_x, 'y': tap_y, 'duration': 1.0 + }) + print("카드 롱프레스 완료") + self.wait_seconds(1) + + def handle_device_change_alert(self): + """이미 인증된 디바이스 알럿 처리 - 취소 누르고 종료""" + if self.is_android(): + locators = [ + (By.XPATH, '//*[@text="취소"]'), + (By.XPATH, '//android.widget.Button[@text="취소"]'), + ] + else: + locators = [ + (By.XPATH, '//*[@name="취소"]'), + (By.XPATH, '//*[@label="취소"]'), + (By.XPATH, '//XCUIElementTypeAlert//XCUIElementTypeButton[1]'), + ] + for locator in locators: + if self.try_click(locator, timeout=1): + print("디바이스 변경 알럿 감지 - 취소 클릭") + self.wait_seconds(1) + return True + return False + + def full_entrance_card_flow(self): + self.go_to_entrance_card_tab() + + if self.handle_device_change_alert(): + print("✅ 출입카드 테스트 완료 (디바이스 변경 알럿 취소)") + return True + + self.long_press_card() + print("✅ 출입카드 테스트 완료") + return True