|
|
@ -3,44 +3,45 @@ import pytest |
|
|
|
from config import * |
|
|
|
from config import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup(): |
|
|
|
class Test_Admin(): |
|
|
|
# setup 步骤 |
|
|
|
def setup_class(self): |
|
|
|
driver = sync_playwright().start() |
|
|
|
# setup 步骤 |
|
|
|
browser = driver.chromium.launch(headless=False) |
|
|
|
print('setup') |
|
|
|
context = browser.new_context() |
|
|
|
driver = sync_playwright().start() |
|
|
|
page = context.new_page() |
|
|
|
browser = driver.chromium.launch(headless=False) |
|
|
|
|
|
|
|
self.context = browser.new_context() |
|
|
|
|
|
|
|
self.page = self.context.new_page() |
|
|
|
def test_admin_login(page): |
|
|
|
|
|
|
|
# 访问医馆首页 |
|
|
|
def teardown_class(self): |
|
|
|
page.goto(BASE_URL) |
|
|
|
print('teardown') |
|
|
|
|
|
|
|
# teardown 步骤 |
|
|
|
# 输入手机号后失焦触发获取医馆列表事件 |
|
|
|
self.context.close() |
|
|
|
mobile_input = page.get_by_placeholder('请输入手机号') |
|
|
|
self.page.close() |
|
|
|
mobile_input.fill(ADMIN_ACCOUNT) |
|
|
|
|
|
|
|
mobile_input.blur() |
|
|
|
def test_admin_login(self): |
|
|
|
|
|
|
|
# 访问医馆首页 |
|
|
|
# 选择厚生堂诊所 |
|
|
|
self.page.goto(BASE_URL) |
|
|
|
page.get_by_placeholder('请选择诊所名称').click() |
|
|
|
|
|
|
|
page.get_by_text(CLINIC_NAME).click() |
|
|
|
# 输入手机号后失焦触发获取医馆列表事件 |
|
|
|
|
|
|
|
mobile_input = self.page.get_by_placeholder('请输入手机号') |
|
|
|
# 输入密码 |
|
|
|
mobile_input.fill(ADMIN_ACCOUNT) |
|
|
|
page.get_by_placeholder('请输入密码').fill(ADMIN_PWD) |
|
|
|
mobile_input.blur() |
|
|
|
|
|
|
|
|
|
|
|
#点击登录 |
|
|
|
# 选择厚生堂诊所 |
|
|
|
page.get_by_role('button', name='登录').click() |
|
|
|
self.page.get_by_placeholder('请选择诊所名称').click() |
|
|
|
|
|
|
|
self.page.get_by_text(CLINIC_NAME).click() |
|
|
|
# 验证测试结果 |
|
|
|
|
|
|
|
assert page.locator('.max-logo').inner_text == CLINIC_NAME |
|
|
|
# 输入密码 |
|
|
|
|
|
|
|
self.page.get_by_placeholder('请输入密码').fill(ADMIN_PWD) |
|
|
|
# 临时代码 |
|
|
|
|
|
|
|
page.wait_for_timeout(2000) |
|
|
|
#点击登录 |
|
|
|
|
|
|
|
self.page.get_by_role('button', name='登录').click() |
|
|
|
def teardown(context, page): |
|
|
|
|
|
|
|
# teardown 步骤 |
|
|
|
print(self.page.locator('.max-logo').inner_text()) |
|
|
|
context.close() |
|
|
|
# 验证测试结果 |
|
|
|
page.close() |
|
|
|
assert self.page.locator('.max-logo').inner_text() == CLINIC_NAME |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 临时代码 |
|
|
|
if __name__ == '__main__': |
|
|
|
self.page.wait_for_timeout(2000) |
|
|
|
pytest.main('-vs') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|