-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (33 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const puppeteer = require('puppeteer');
(async () => {
try {
const browser = await puppeteer.launch({
headless: false,
args: [
'--no-sandbox',
'--disable-setuid-sandbox'
]
})
const page = await browser.newPage()
await page.goto('https://www.userede.com.br')
const toggledMenu = await page.$('.my-account-gtm-trigger')
await toggledMenu.click()
await page._client.send('Animation.setPlaybackRate', { playbackRate: 15 })
await page.evaluate(() => {
document.querySelector('#usernameField').value = ''
document.querySelector('#passwordField').value = ''
})
const loginBtn = await page.$('#form-login-entrar')
await loginBtn.click()
await page.waitForNavigation({ timeout: 0, waitUntil: ['load', 'domcontentloaded', 'networkidle0'] })
const user = await page.evaluate(() => {
const user = window.angular.element(document.querySelector('body')).scope().user
return user
})
console.log(user.token)
await page.screenshot({path: 'example.png'})
await browser.close()
} catch (e) {
console.error(e)
}
})();