Some tips for Puppeteer

1.Type some text into input tags

await page.type('input.form-control[placeholder="Your Email"]',"something you want to input",{delay:500});

the code show above will type “something you want to input” into the <input class=”form-control” placeholder=”Your Email”>

2.Simulate button click


the code show above will click the
<input value=”Login”>

3. Tabs control (Switch foreground and background)

const allPages = await browser.pages(); // get all the tabs in browser
await allPages[1].bringToFront();       
// select 1 and bring it to foreground , notice ! allPages[0] always be a blank page created by puppeteer

4. Simulate keyboard input


5. Others

$$ select all the match element and $ just select the first one!

for more detail visit the puppeteer api document!

Leave a Reply

Your email address will not be published. Required fields are marked *