我是编码新手,被要求为公司的 Web 登录做一个测试,他们希望我实现模块 unitestt 和 playwright 测试生成器工具。这就是我到目前为止所拥有的。我不得不将 run 与 test_1 分开,因为 unittest 在读取 chromium 行时失败,但现在它只打开浏览器,所以我该怎么做才能让它运行整个测试?
from playwright.sync_api import Playwright, sync_playwright
from locators import Locators_evou
import unittest
class Test(unittest.TestCase):
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(channel ="chrome", headless=False,slow_mo=500)
context = browser.new_context()
page = context.new_page()
page.goto("http://localhost:3000/")
def test_1(page):
page.click(Locators_evou.user_Log)
page.fill(Locators_evou.user_Log, "Liliana")
page.click(Locators_evou.password_log)
page.fill(Locators_evou.password_log, "1234")
page.check(Locators_evou.session_Log)
page.click(Locators_evou.login_log)
assert page.is_visible("¡Bienvenido!")
with sync_playwright() as playwright:
run(playwright)
if __name__=="__main__":
unittest.main()