Created
March 27, 2018 16:56
-
-
Save DavidMellul/05a3625d95bd268eda6c9c8514fe397e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Dependencies and stuff, who cares ? | |
| // ES6 way | |
| (async () => { | |
| // Browser launched | |
| const browser = await puppeteer.launch(); | |
| // New tab created | |
| const tab = await browser.newPage(); | |
| // Navigate to a website | |
| await tab.goto('http://www.website.fr/'); | |
| // Click somewhere | |
| await tab.click('#somewhereCSSSelector'); | |
| // Type something somewhere | |
| await tab.type('#somewhereCSSSelector', 'something'); | |
| })(); | |
| // For some of you who might be unfamiliar with the syntax | |
| // (function(){})() creates an anonymous function and runs it, just like that. | |
| // In ES6, the above code is translated into ( () => {} )() | |
| // Making use of async/await statements to make the code look sequential without callback hell, we get => | |
| // ( async() => {} )() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment