You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
from playwright.sync_api import sync_playwright |
|
import pytest |
|
from config import * |
|
|
|
|
|
def setup(): |
|
# setup 步骤 |
|
driver = sync_playwright().start() |
|
browser = driver.chromium.launch(headless=False) |
|
context = browser.new_context() |
|
page = context.new_page() |
|
|
|
|
|
def test_admin_login(page): |
|
# 访问医馆首页 |
|
page.goto(BASE_URL) |
|
|
|
# 输入手机号后失焦触发获取医馆列表事件 |
|
mobile_input = page.get_by_placeholder('请输入手机号') |
|
mobile_input.fill(ADMIN_ACCOUNT) |
|
mobile_input.blur() |
|
|
|
# 选择厚生堂诊所 |
|
page.get_by_placeholder('请选择诊所名称').click() |
|
page.get_by_text(CLINIC_NAME).click() |
|
|
|
# 输入密码 |
|
page.get_by_placeholder('请输入密码').fill(ADMIN_PWD) |
|
|
|
#点击登录 |
|
page.get_by_role('button', name='登录').click() |
|
|
|
# 验证测试结果 |
|
assert page.locator('.max-logo').inner_text == CLINIC_NAME |
|
|
|
# 临时代码 |
|
page.wait_for_timeout(2000) |
|
|
|
def teardown(context, page): |
|
# teardown 步骤 |
|
context.close() |
|
page.close() |
|
|
|
|
|
if __name__ == '__main__': |
|
pytest.main('-vs') |