-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (33 loc) · 1.28 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const puppeteer = require('puppeteer');
require('dotenv').config()
async function BrowserRun() {
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage()
await page.goto('https://betamoodle.iiitvadodara.ac.in/login/index.php')
await page.setViewport({ width: 1920, height: 1080 });
const LoginID = await page.waitForSelector('div > .form-control');
await LoginID.type(process.env.STUDENT_ID)
const Password = await page.waitForSelector('div > .form-control[type="password"]')
await Password.type(process.env.STUDENT_PASSWORD)
// await page.keyboard.press('Enter')
// try {
// await page.click("button[type=submit]")
// } catch (error) {
// console.log(error.message);
// }
try {
await page.click('#loginbtn')
await page.waitForNavigation({ waitUntil: 'networkidle0' , timeout: 10000 });
} catch (error) {
console.log(error.message);
}
const users = await page.$$eval('.listentry .user a', elements => elements.map(element => element.textContent));
console.log(users);
await page.screenshot({ path: 'moodle.png' , fullPage: true})
browser.close()
}
try {
BrowserRun()
} catch (error) {
console.log(error);
}