-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
import "dotenv/config";
import { Stagehand } from "@browserbasehq/stagehand";
async function main() {
const stagehand = new Stagehand({
env: "LOCAL",
disableAPI: true,
verbose: 0
});
await stagehand.init();
const page = stagehand.context.pages()[0];
// 主执行函数
async function test() {
await page.goto("https://www.stagehand.dev/");
const selector = page.locator("//img[@alt='Stagehand']")
const count = await selector.count();
const visible = await selector.isVisible()
console.log("🚀 ~ test ~ count:", count,visible)
}
await test()
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
package.json
{
"name": "my-stagehand-app",
"type": "module",
"scripts": {
"build": "tsc",
"start": "tsx index.ts"
},
"dependencies": {
"@ai-sdk/openai-compatible": "^1.0.30",
"@browserbasehq/stagehand": "^3.1.0-alpha-a7d29decee0f7d12e2437267b9eef1795d3b4e3a",
"dotenv": "^16.4.7",
"openai": "^6.17.0",
"zod": "^4.3.6"
},
"devDependencies": {
"tsx": "^4.19.2",
"typescript": "^5.0.0"
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels