-
-
Save vielhuber/53e4085b029089ec48bd0f5b954a6b50 to your computer and use it in GitHub Desktop.
puppeteer stagehand vodafone restart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VODAFONE_PASSWORD=... | |
OPENAI_API_KEY=... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install puppeteer | |
npm install @browserbasehq/stagehand zod && npx playwright install-deps && npm exec playwright install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import puppeteer from 'puppeteer'; | |
const browser = await puppeteer.launch({ | |
headless: true, | |
ignoreHTTPSErrors: true, | |
args: [ | |
'--disable-gpu', | |
'--disable-dev-shm-usage', | |
'--disable-setuid-sandbox', | |
'--no-first-run', | |
'--no-sandbox', | |
'--no-zygote', | |
'--single-process', | |
'--window-size=1920,1080' | |
], | |
defaultViewport: { | |
width: 1920, | |
height: 1080 | |
} | |
}); | |
const page = await browser.newPage(); | |
await page.setDefaultTimeout(5000); | |
await page.goto('http://192.168.0.1'); | |
await page.locator('#Password').fill(process.env.VODAFONE_PASSWORD); | |
await page.locator('#LoginBtn').click(); | |
await new Promise(resolve => setTimeout(() => resolve(), 2000)); | |
if ((await page.$('#OneUserLoginMsgOKBtn')) !== null) { | |
page.locator('#OneUserLoginMsgOKBtn').click(); | |
} | |
await page.locator('a[href*="settings_device"]').click(); | |
await page.locator('#led_enable').click(); | |
await page.waitForSelector('#beforeApplyMsg'); | |
await page.locator('#applyButton2').click(); | |
await page.waitForSelector('#afterApplyMsg'); | |
await browser.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Stagehand } from '@browserbasehq/stagehand'; | |
const stagehand = new Stagehand({ | |
headless: true, | |
env: 'LOCAL', | |
debugDom: true, | |
enableCaching: true, | |
verbose: 0 | |
}); | |
await stagehand.init(); | |
await stagehand.page.goto('http://192.168.0.1'); | |
await stagehand.page.act({ | |
action: 'enter %password% into the password field', | |
variables: { password: process.env.VODAFONE_PASSWORD } | |
}); | |
await stagehand.page.act({ action: 'click the login button' }); | |
await stagehand.page.act({ action: 'if a message appears, that another user is logged in, click "OK"' }); | |
await stagehand.page.act({ action: 'click on "Einstellungen"' }); | |
// manual call, since the radio button is invisible | |
await stagehand.page.locator('#led_enable').click(); | |
await new Promise(resolve => setTimeout(() => resolve(), 5000)); | |
await stagehand.page.act({ action: 'click on "Anwenden"' }); | |
await stagehand.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment