Playwright
开始
import re
from playwright.sync_api import Page, expect, sync_playwright
# https://playwright.dev/python/docs/writing-tests
def test_has_title(page: Page):
page.goto("https://playwright.dev/")
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))
# 如果成功会继续往下走,如果失败会抛出异常
def test_get_started_link(page: Page):
page.goto("https://playwright.dev/")
# Click the get started link.
page.get_by_role("link", name="Get started").click()
# Expects page to have a heading with the name of Installation.
expect(page.get_by_role("heading", name="Installation")).to_be_visible()操纵浏览器
自动生成测试代码
使用代理
异步写法
最后更新于