Created
June 1, 2021 10:20
-
-
Save manojsinghnegiwd/9855ce83ef5b64e671067c4337b16302 to your computer and use it in GitHub Desktop.
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
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