Created
September 3, 2017 15:33
-
-
Save M4R14/92592dede5ef769453d151c2c7a99f55 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
| const puppeteer = require('puppeteer'); | |
| const LOGIN = async (page) { | |
| const USER = { | |
| username : "<username>", | |
| password : "<password>" | |
| } | |
| // dom element selectors | |
| const USERNAME_SELECTOR = '#login_field'; | |
| const PASSWORD_SELECTOR = '#password'; | |
| const BUTTON_SELECTOR = '#login > form > div.auth-form-body.mt-3 > input.btn.btn-primary.btn-block'; | |
| await page.click(USERNAME_SELECTOR); | |
| await page.type(USER.username); | |
| await page.click(PASSWORD_SELECTOR); | |
| await page.type(USER.password); | |
| await page.click(BUTTON_SELECTOR); | |
| await page.waitForNavigation(); | |
| } | |
| async function run() { | |
| const browser = await puppeteer.launch(); | |
| const page = await browser.newPage(); | |
| await page.goto('https://github.com'); | |
| await page.screenshot({path: 'screenshots/github.png'}); | |
| await LOGIN(page); | |
| await page.screenshot({path: 'screenshots/LOGIN.png'}); | |
| browser.close(); | |
| } | |
| run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment