Playwright
-
【iTestCat】测试Playwright脚本
编写测试代码 创建一个名为 test_itestcat.py 的文件,并写入以下代码:
123456789def test_itestcat(page):# 打开 itestcat.compage.goto("https://itestcat.com")# 验证页面标题assert "itestcat" in page.title()# 在页面中查找特定的元素 (可以根据需求调整)assert page.locator("text=首页").is_visible()运行测试 在终端中运行以下命令来执行测试: pytest test_itestcat.py 详细解释: page.goto() 用于让浏览器导航到指定的 URL,这里是 itestcat.com。 page.…
-
【iTestCat】通过 pytest 使用 Playwright
1. 安装 pytest 首先,你需要确保你的环境中安装了 pytest。如果没有安装,可以通过以下命令安装: pip install pytest 2. 安装 Playwright 及其 pytest 插件 为了使用 Playwright 进行测试,你需要安装 Playwright 和 pytest-playwright 插件。运行以下命令来安装: pip…
-
【iTestCat】通过Node.js安装Playwright
要安装 Playwright,按照以下步骤操作: 1. 安装 Node.js 首先,你需要确保你的系统上安装了 Node.js。你可以通过以下命令检查是否已安装 Node.js: node -v 如果没有安装,可以去 Node.js 官方网站 下载并安装。 2. 初始化项目 在你的项目目录中运行以下命令来初始化一个新项目: npm init -y 3. 安装…