From e7f85daba33db7fd77bdeec8ff5cbb47952bf00a Mon Sep 17 00:00:00 2001 From: RogerWork Date: Sun, 11 Aug 2024 09:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=AE=8C=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ test_demo.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .gitignore create mode 100644 test_demo.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..23279da --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea/ +__pycache__/ +.pytest_cache/ +venv/ \ No newline at end of file diff --git a/test_demo.py b/test_demo.py new file mode 100644 index 0000000..931bf7e --- /dev/null +++ b/test_demo.py @@ -0,0 +1,41 @@ +from playwright.sync_api import sync_playwright +import pytest + +def setup(): + # setup 步骤 + driver = sync_playwright().start() + browser = driver.chromium.launch(headless=False) + context = browser.new_context() + page = context.new_page() + + +@ pytest.fixture +def test_admin_login(page): + # 访问医馆首页 + page.goto('http://ankangfulu.yhz.com') + + # 输入手机号后失焦触发获取医馆列表事件 + mobile_input = page.get_by_placeholder('请输入手机号') + mobile_input.fill('18611659484') + mobile_input.blur() + + # 选择厚生堂诊所 + page.get_by_placeholder('请选择诊所名称').click() + page.get_by_text('厚生堂(测试)诊所').click() + + # 输入密码 + page.get_by_placeholder('请输入密码').fill('admin123') + + #点击登录 + page.get_by_role('button', name='登录').click() + + # 验证测试结果 + assert page.locator('.max-logo').inner_text == '厚生堂(测试)诊所' + + # 临时代码 + page.wait_for_timeout(2000) + +def teardown(context, page): + # teardown 步骤 + context.close() + page.close() \ No newline at end of file