-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpn.js
61 lines (52 loc) · 1.67 KB
/
vpn.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
50
51
52
53
54
55
56
57
58
59
60
61
require('colors');
require('./env.js');
var wd = require('wd');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
var asserters = wd.asserters;
var browser = wd.promiseChainRemote();
// optional extra logging
browser.on('status', function(info) {
console.log(info.cyan);
});
browser.on('command', function(eventType, command, response) {
console.log(' > ' + eventType.cyan, command, (response || '').grey);
});
browser.on('http', function(meth, path, data) {
console.log(' > ' + meth.magenta, path, (data || '').grey);
});
let WAIT_MLS = 20000;
let POLL_FREQ = 1000;
let PPTP = 'pptp'
let DHCP = 'dynamic'
function setupInet(inetType) {
browser.init({browserName:'chrome'})
.setWindowSize(1400, 1024)
.get('http://192.168.0.1/bsc_wan.php')
.title()
.should.become('D-LINK SYSTEMS, INC. | WIRELESS ROUTER | HOME')
.waitForElementById('loginpwd')
.type(PWD)
.waitForElementById('noGAC')
.click()
.waitForElementById('wan_ip_mode', asserters.isVisible, WAIT_MLS, POLL_FREQ)
.type(inetType)
.elementById('topsave')
.click()
.waitForElementById('menu', asserters.isVisible, WAIT_MLS, POLL_FREQ)
.get('http://192.168.0.1/status.php')
.waitForElementById('st_networkstatus', asserters.textInclude('Connected'), WAIT_MLS, POLL_FREQ)
.fin(function() { return browser.quit(); })
.done();
}
var vpn = {};
vpn.connectVPN = function() {
setupInet(PPTP);
}
vpn.connectDHCP = function() {
setupInet(DHCP);
}
module.exports = vpn;