Skip to content

Instantly share code, notes, and snippets.

@manojsinghnegiwd
Created June 1, 2021 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manojsinghnegiwd/9855ce83ef5b64e671067c4337b16302 to your computer and use it in GitHub Desktop.
Save manojsinghnegiwd/9855ce83ef5b64e671067c4337b16302 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
const googleSearch = async () => {
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
await page.viewport({
width: 1920,
height: 1080
})
await page.goto("https://www.google.com")
await page.type('[aria-label="Search"]', "steve jobs")
const element = await page.$('[aria-label="Search"]')
await element.press('Enter');
await page.waitForNavigation({ waitUntil: "networkidle2" })
await Promise.all([
page.click("a > h3"),
page.waitForNavigation({ waitUntil: "networkidle2" })
])
}
googleSearch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment