feat: 基于 UI 自动化最佳实践的测试框架骨架搭建

- tests/config: 环境配置 (.yaml) + 配置加载器
- tests/utils: 日志工具 + 测试数据生成器
- tests/web: Playwright conftest + Page Object 基类 + 登录页 + 导航栏组件 + 登录用例(6条)
- tests/app: Appium conftest + Page Object 基类 + 司机端首页 + 登录用例(3条)
- pytest.ini: markers(p0/p1/p2/smoke/web/app) + 运行配置
- 所有用例按最佳实践采用 Page Object 模式 + data-testid 优先定位 + 失败自动截图
This commit is contained in:
xst
2026-07-15 10:24:22 +08:00
parent 26ef99f7e7
commit aade9e39d0
17 changed files with 1034 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
"""司机端首页 — Page ObjectApp 端)。
Usage:
from tests.app.pages.driver_home_page import DriverHomePage
home = DriverHomePage(driver, platform="android")
home.go_to_order_list()
"""
from appium.webdriver.webdriver import WebDriver
from tests.app.pages.base_page import AppBasePage
class DriverHomePage(AppBasePage):
"""运八司机端 APP 首页。"""
def __init__(self, driver: WebDriver, platform: str = "android"):
super().__init__(driver, platform)
# ⚠️ 以下 accessibility_id 需要根据实际 APP UI 确认
self.order_tab = "tab_orders" # 运单 tab
self.mine_tab = "tab_mine" # 我的 tab
self.home_tab = "tab_home" # 首页 tab
self.notification_badge = "badge_notification"
def is_displayed(self) -> bool:
"""检查首页是否已展示。"""
try:
self.wait_visible_by_id(self.home_tab, timeout_s=10)
return True
except Exception:
return False
def go_to_order_list(self) -> None:
"""点击进入运单列表。"""
self.tap_by_id(self.order_tab)
def go_to_mine(self) -> None:
"""点击进入「我的」页面。"""
self.tap_by_id(self.mine_tab)
def get_notification_count(self) -> str:
"""获取通知角标数量。"""
element = self.driver.find_element(
self.driver.find_element.ACCESSIBILITY_ID, self.notification_badge
)
return element.text if element else "0"