Files
smart-management-auto-test/Joyhub_ui_auto_test/tests/test_app_page.py
zhouqi a94eb5dbbe feat: 新增JoyHub UI自动化测试目录
1. 新增 Joyhub_ui_auto_test/ 目录:
   - tests/ - 测试用例目录
   - pages/ - 页面元素定位
   - config/ - 配置文件
   - utils/ - 工具类
   - test_data/ - 测试数据
   - reports/ - 测试报告
   - webapp-testing/ - WebApp测试相关

2. 配置文件:
   - pytest.ini - pytest配置
   - requirements.txt - 依赖列表
   - README.md - 项目说明
2026-05-13 16:01:25 +08:00

56 lines
2.0 KiB
Python

from pathlib import Path
import re
import sys
import pytest
from playwright.sync_api import expect
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from config.settings import settings
from utils.logger import get_logger
logger = get_logger(__name__)
def test_app_page_key_content_and_download_links_visible(page):
logger.info("使用 pytest-playwright 统一无头浏览器配置")
logger.info("打开 Download the App 页面")
page.goto("/app", wait_until="domcontentloaded")
logger.info("校验 App 下载页地址和页面已加载")
expect(page).to_have_url(re.compile(r".*/app/?$"), timeout=settings.default_timeout)
expect(page.locator("body")).to_be_visible(timeout=settings.default_timeout)
logger.info("动态校验下载入口展示,不绑定具体版本文案")
download_links = page.locator('section main a[href]')
expect(download_links.first).to_be_visible(timeout=settings.default_timeout)
download_link_count = download_links.count()
logger.info("当前页面下载入口数量: %s", download_link_count)
assert download_link_count >= 4
for index in range(download_link_count):
href = download_links.nth(index).get_attribute("href")
logger.info("当前下载入口 href: %s", href)
assert href is not None
def test_app_page_how_to_download_apk_button_visible(page):
logger.info("使用 pytest-playwright 统一无头浏览器配置")
logger.info("打开 Download the App 页面")
page.goto("/app", wait_until="domcontentloaded")
logger.info("动态校验下载说明按钮可见,不绑定按钮文案")
how_to_download_button = page.locator("section main button").first
expect(how_to_download_button).to_be_visible(timeout=settings.default_timeout)
expect(how_to_download_button).to_be_enabled(timeout=settings.default_timeout)
if __name__ == "__main__":
raise SystemExit(pytest.main([str(Path(__file__))]))