npm i puppeteer
const puppeteer = require('puppeteer'); function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function run() { const browser = await puppeteer.launch({ headless: false, args: ['--start-maximized'], devtools: false }); const page = await browser.newPage(); page.setViewport({ width: 1920, height: 919 }) // console.log(page) await page.goto('http://xxxxxxx.com'); await sleep(1000) await page.type("input[placeholder='请输入用户名']", 'fmg') await sleep(1000) await page.type("input[placeholder='请输入密码']", '3333333333') await sleep(1000) await page.locator(".login_btn").click() await sleep(1000) // 展开设备列表 await page.locator('.el-menu .el-sub-menu:nth-child(1)').click() await sleep(1000) // 点击设备列表 await page.locator('.el-menu .el-menu-item:nth-child(2)').click() await sleep(1000) // 选择充电 await page.locator('.nav_header li:nth-child(4)').click() await sleep(1000) // 点击待配置 await page.locator('.card6 .nav_box li:nth-child(2)').click() await sleep(1000) // 点击带有 添加设备 的按钮 await page.locator(".selects button:nth-child[2]").click() } run();
标签:await,chrome,javascript,puppeteer,click,locator,sleep,page,1000 From: https://www.cnblogs.com/fmg0224/p/18381010