-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
38 lines (29 loc) · 982 Bytes
/
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
const { Builder } = require('selenium-webdriver');
const CommonPage = require('./pages/common');
const HomePage = require('./pages/home');
const UserPage = require('./pages/user');
const { writeJson } = require('./util');
(async function() {
let driver;
try {
driver = await new Builder().forBrowser('chrome').build();
// go to home
const common = new CommonPage(driver);
await common.goToPage(HomePage.BASE_URL);
// get user links
const userLinks = await common.getLinks(HomePage.USER_LINKS_LOCATOR);
await writeJson('users.json', userLinks);
// get repl links
let replLinks = [];
for (let userLink of userLinks) {
await common.goToPage(userLink);
const userReplLinks = await common.getLinks(UserPage.REPL_LINKS_LOCATOR);
replLinks = replLinks.concat(userReplLinks);
}
await writeJson('repls.json', replLinks);
} catch (err) {
console.error(err);
} finally {
await driver.quit();
}
})();