playwright 用起来咋样。比 selenium
process.env.PYTHONIOENCODING = "utf-8";
import { Stagehand } from "@browserbasehq/stagehand";
import StagehandConfig from "./stagehand.config.js";
import { CustomOpenAIClient } from "./llm_clients/customOpenAI_client.js";
import OpenAI from "openai";
import dotenv from "dotenv";
import assert from "assert";
// 加载环境变量
dotenv.config();
assert(process.env.DASHSCOPE_API_KEY, "DASHSCOPE_API_KEY must be set in environment variables"); // [1]
async function performSearch(stagehand: Stagehand) {
const page = stagehand.page;
// 断言页面导航成功
const response = await page.goto("https://www.baidu.com");
assert(response?.ok(), Failed to load Baidu homepage. Status: ${response?.status()}); // [2]
// 断言搜索框存在并可输入
const typeResult = await page.act('type "Stagehand" into the search box');
assert(typeResult.success, Failed to type into search box: ${typeResult.message}); // [3]
// 断言搜索按钮点击成功
const clickResult = await page.act("click the search button");
assert(clickResult.success, Failed to click search button: ${clickResult.message}); // [4]
// 可选:断言搜索结果页面包含预期内容
await page.waitForSelector("#content_left", { timeout: 5000 });
const searchResults = await page.$eval("#content_left", el => el.textContent);
assert(searchResults?.includes("Stagehand"), "Search results did not contain expected term"); // [5]
}
(async () => {
let stagehand: Stagehand | null = null; // 显式声明类型并初始化为 null
try {
stagehand = new Stagehand({
...StagehandConfig,
llmClient: new CustomOpenAIClient({
modelName: "Qwen3-14B",
client: new OpenAI({
apiKey:"xxxxxxxxxxxxxxxxxxxxx",
baseURL: "http://xx.xx.x.xx:xx/v1/chat/completions",
}),
}),
});
await stagehand.init();
await performSearch(stagehand);
} catch (error) {
console.error("Test failed:", error);
process.exit(1);
} finally {
// 安全清理资源
try {
if (stagehand) await stagehand.close();
} catch (closeError) {
console.error("Failed to close Stagehand:", closeError);
}
}
})();
我这个控制台目前一直提示这样
ERROR: API key for openai not found in environment variable OPENAI_API_KEY
category: "init"
[2025-08-18 15:06:17.878 +0800] INFO: Custom LLM clients are currently not supported in API mode
category: "init"
我看和模型对话了。但是就执行了打开页面操作。那个 goto 又是 playwright 的。那个 act 也没执行
什么录制工具呢?大佬分享一下
那什么才叫好的用例呢
要调研使用的。这个的话。自己本地化部署模型应该就能解决你说的那个敏感信息问题吧
我没配置 deepseek.我以为你的意思是直接不能配置呢.我用的是 qwen3-14b。你可以先通过 curl 命令获取 deepseek 模型返回的数据结构。然后再一步步调整成 stagehand 适配的结构。最后应该就正常了。我之前是这样的。但是我发现我把模型直接写道那个用例.ts。没配置那些什么 strem,enale_thinking 这些参数就能正常使用
为啥这样说?
Nice! 我找到配置自定义大模型的方式了。在官方文档上边https://docs.stagehand.dev/examples/custom_llms
之前白走了好多弯路》谢谢大佬的灵感提供!!

我看官方文档上是支持 deepseek 的
。你是直接新建了个 python 项目去跑这个脚本的吗?我目前也卡壳在这个配置国内模型上边。它的文档和 github 上都没有明确说明这个配置国内模型的地方。但是说支持自定义 llm
每次调试自动化脚本,花费最多的其实就是元素定位,有的元素尽可能地时候 xpath 了,但是也还是定位失败,有的前一天调试好了,但是第二天又不好使了。前端页面并没有什么改动。目前接触的这个 web 应用动态元素比较多
是的,主要是前端 UI 自动化测试
想看看你的用例生成提示词 md 文件,能分享一下吗
请问目前使用的是什么框架呢?
确实,所以我来社区求助大家了。
好的,感谢回答,我试一下
痛点
怎样在研发每次更一个小功能,自动触发自动化测试
目的每次研发发版一个小版本,能实时感知到,然后可以跑一下自动化的冒烟测试,来判断当前版本是否可以测试
确实服务器没有想推动属实不易,往这个方向走就是得有成本支持,不然真搞不下去。不过你的半成品来看,还是很不错的。我努力靠近。
给大佬点赞,我试了一下那个根据 prd 生成测试用例的,还是挺好用的。生成用例准确度还可以
为啥推不起来哇,听你的描述感觉还不错的样子。你的 demo 和 ppt 有上传到 github 或者 gitee 吗?想学习一下。我目前打算推动一下这些在自己小组。
实际使用起来效果怎么样
您这边有使用示例吗
有出系列教程吗
好的,谢谢!
好的,您平时 web 自动化测试都是用的影刀吗?