-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwdconfig.js
More file actions
109 lines (100 loc) · 3.52 KB
/
wdconfig.js
File metadata and controls
109 lines (100 loc) · 3.52 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*jshint node: true*/
'use strict';
var utils = require('./lib/utils'),
path = require('path'),
os = require('os');
var DriverConfig = {
selenium: {
name: 'Selenium Standalone',
bin: null,
url: getSeleniumStandaloneUrl,
version: '2.47.1',
filePattern: 'selenium-server-standalone-.*[.]jar',
install: true,
applicable: function() { return true; },
args: function(driver, dir) {
return ['-jar', path.resolve(dir, getDriverFileName(driver.url(driver.version)))];
}
},
chrome: {
name: 'Chrome Driver',
bin: 'chromedriver',
url: getChromeDriverUrl,
version: '2.19',
filePattern: 'chromedriver_mac32[.]zip',
install: true,
extract: true,
applicable: function() { return true; },
args: function(driver, dir) {
return ['-Dwebdriver.chrome.driver=' + path.resolve(dir, getDriverExecutable(driver.bin))];
}
},
ie: {
name: 'IE Driver',
bin: 'IEDriverServer',
url: getIEDriverUrl,
version: '2.47.0',
filePattern: 'IEDriverServer_.*[.]zip',
install: true,
extract: true,
applicable: function() {
return (/^win/).test(os.platform());
},
args: function(driver, dir) {
return ['-Dwebdriver.ie.driver=' + path.resolve(dir, getDriverExecutable(driver.bin))];
}
}
};
function getSeleniumStandaloneUrl(version) {
// Example output: http://selenium-release.storage.googleapis.com/2.41/selenium-server-standalone-2.41.0.jar
var tpl = 'http://selenium-release.storage.googleapis.com/{version}/selenium-server-standalone-{patch}.jar';
var patch = version;
version = version.split('.').slice(0,2).join('.');
return utils.format(tpl, {
version: version,
patch: patch
});
}
function getChromeDriverUrl(version) {
// Example output: http://chromedriver.storage.googleapis.com/2.10/chromedriver_mac32.zip
var tpl = 'http://chromedriver.storage.googleapis.com/{version}/chromedriver_{platform}.zip';
var platform = '';
if (os.platform() === 'linux') {
platform = 'linux' + (os.arch() === 'x64' ? '64' : '32');
} else if (os.platform() === 'darwin') {
platform = 'mac32';
} else if (os.platform() === 'win32') {
platform = 'win32';
} else {
return null;
}
return utils.format(tpl, {
version: version,
platform: platform
});
}
function getIEDriverUrl(version) {
// Example output: http://selenium-release.storage.googleapis.com/2.41/IEDriverServer_x64_2.41.0.zip
// Example output: http://selenium-release.storage.googleapis.com/2.41/IEDriverServer_Win32_2.41.0.zip
// versioning: major.minor.build.revision. e.g. v2.41.0.2
var tpl = 'http://selenium-release.storage.googleapis.com/{version}/IEDriverServer_{platform}_{patch}.zip';
var platform = os.arch() === 'x64' ? 'x64' : 'Win32';
var patch = version;
version = version.split('.').slice(0,2).join('.');
return utils.format(tpl, {
version: version,
patch: patch,
platform: platform
});
}
function getDriverFileName(driverUrl) {
return require('url').parse(driverUrl).pathname.split('/').pop();
}
function getDriverExecutable(driverUrl) {
var file = require('url').parse(driverUrl).pathname.split('/').pop();
return file + (isWindows() ? '.exe' : '');
}
function isWindows() {
return (/^win/).test(os.platform());
}
module.exports = DriverConfig;