-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (31 loc) · 972 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
39
40
require('dotenv').config();
require('chromedriver');
require('./util/validate-environment')();
const { Builder } = require('selenium-webdriver');
const LoginPage = require('./pages/login');
const WorkspacesPage = require('./pages/workspaces');
const DownloadPage = require('./pages/download');
(async function() {
let driver;
try {
driver = await new Builder().forBrowser('chrome').build();
const login = new LoginPage(driver);
await login.login();
const workspaces = new WorkspacesPage(driver);
await workspaces.prepareToDownload();
const download = new DownloadPage(driver);
let workspaceName;
do {
await workspaces.goToWorkspaces();
driver.sleep(1000);
workspaceName = await workspaces.getWorkspaceToDownload();
if (workspaceName) {
await download.download(workspaceName);
}
} while (workspaceName);
} catch (err) {
throw err;
} finally {
await driver.quit();
}
})();