好的。我发现这个的相关资料也挺少的。我在 github 上问问题。也一直没见到有人回复。搜索到的资料都是说这个多厉害。但是具体的落地实现细节都没看到写的
关于这些,有系统的操作做步骤吗?想了解一下规范流程
请问大佬是直接用了一个 python 项目。然后去安装 stagehand 去进行验证使用的吗?
我有自己部署 qwen 的
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 也没执行
什么录制工具呢?大佬分享一下
那什么才叫好的用例呢
要调研使用的。这个的话。自己本地化部署模型应该就能解决你说的那个敏感信息问题吧