Skip to content

Commit 90a635d

Browse files
authored
full url support (#520)
1 parent 0ed8ca4 commit 90a635d

File tree

5 files changed

+80
-34
lines changed

5 files changed

+80
-34
lines changed

docs/API.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ arch [sometimes](https://code.google.com/p/selenium/issues/detail?id=5116#c9).
7070

7171
`baseURL` is used to find the server having the selenium or drivers files.
7272

73+
`fullURL` as an alternative to baseURL it's possible specify full url, ex `https://selenium-release.storage.googleapis.com/4.0-alpha-7/selenium-server-4.0.0-alpha-7.jar`.
74+
7375
`opts.ignoreExtraDrivers` only downloads and installs drivers explicity specified.
7476

7577
`opts.basePath` sets the base directory used to store the selenium standalone `.jar` and drivers. Defaults to current working directory + .selenium/

docs/CLI.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ selenium-standalone start -- -debug
2121
# choose selenium version
2222
selenium-standalone install --version=3.141.59 --baseURL=https://selenium-release.storage.googleapis.com
2323

24+
# exact selenium download url
25+
selenium-standalone install --version=4.0.0-alpha-7 --fullURL=https://selenium-release.storage.googleapis.com/4.0-alpha-7/selenium-server-4.0.0-alpha-7.jar
26+
2427
# choose chrome driver version
2528
selenium-standalone install --drivers.chrome.version=87.0.4280.20 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com
2629

@@ -35,6 +38,9 @@ selenium-standalone start -- -role hub
3538
selenium-standalone start -- -role node -hub http://localhost:4444/grid/register
3639
selenium-standalone start -- -role node -hub http://localhost:4444/grid/register -port 5556
3740

41+
# don't forget to specify downloaded version for v4 alpha
42+
./bin/selenium-standalone start --version=4.0.0-alpha-7
43+
3844
# If you have a complex configuration with numerous options or if you want to keep a clear configuration changes history,
3945
# you can specify the options in a configuration file :
4046
selenium-standalone install --config=/path/to/config.json

lib/compute-download-urls.js

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,60 +42,70 @@ async function computeDownloadUrls(opts) {
4242
// 2.44.0 would be `patch`, 2.44 `minor`, 2 `major` as per semver
4343

4444
const downloadUrls = {
45-
selenium: util.format(
46-
urls.selenium,
47-
opts.seleniumBaseURL,
48-
opts.seleniumVersion.replace(/(\d+\.\d+)\.\d+/, '$1'),
49-
opts.seleniumVersion
50-
),
45+
selenium:
46+
opts.seleniumFullURL ||
47+
util.format(
48+
urls.selenium,
49+
opts.seleniumBaseURL,
50+
opts.seleniumVersion.replace(/(\d+\.\d+)\.\d+/, '$1'),
51+
opts.seleniumVersion
52+
),
5153
};
5254
if (opts.drivers.chrome) {
5355
await resolveLatestVersion(opts, 'chrome', opts.drivers.chrome.baseURL + '/LATEST_RELEASE');
5456
if (opts.drivers.chrome.version < 2.23) {
5557
mac32 = true;
5658
}
57-
downloadUrls.chrome = util.format(
58-
urls.chrome,
59-
opts.drivers.chrome.baseURL,
60-
opts.drivers.chrome.version,
61-
getChromeDriverArchitecture(opts.drivers.chrome.version, opts.drivers.chrome.arch)
62-
);
59+
downloadUrls.chrome =
60+
opts.drivers.chrome.fullURL ||
61+
util.format(
62+
urls.chrome,
63+
opts.drivers.chrome.baseURL,
64+
opts.drivers.chrome.version,
65+
getChromeDriverArchitecture(opts.drivers.chrome.version, opts.drivers.chrome.arch)
66+
);
6367
}
6468
if (opts.drivers.ie) {
65-
downloadUrls.ie = util.format(
66-
urls.ie,
67-
opts.drivers.ie.baseURL,
68-
opts.drivers.ie.version.slice(0, opts.drivers.ie.version.lastIndexOf('.')),
69-
getIeDriverArchitecture(opts.drivers.ie.arch),
70-
opts.drivers.ie.version
71-
);
69+
downloadUrls.ie =
70+
opts.drivers.ie.fullURL ||
71+
util.format(
72+
urls.ie,
73+
opts.drivers.ie.baseURL,
74+
opts.drivers.ie.version.slice(0, opts.drivers.ie.version.lastIndexOf('.')),
75+
getIeDriverArchitecture(opts.drivers.ie.arch),
76+
opts.drivers.ie.version
77+
);
7278
}
7379
if (opts.drivers.firefox) {
7480
await resolveLatestVersion(opts, 'firefox', 'https://api.github.com/repos/mozilla/geckodriver/releases/latest');
75-
downloadUrls.firefox = util.format(
76-
urls.firefox,
77-
opts.drivers.firefox.baseURL,
78-
getFirefoxDriverDirectory(opts.drivers.firefox.version),
79-
getFirefoxDriverName(opts.drivers.firefox.version),
80-
getFirefoxDriverVersionForUrl(opts.drivers.firefox.version),
81-
getFirefoxDriverArchitecture(opts.drivers.firefox.version, opts.drivers.firefox.arch)
82-
);
81+
downloadUrls.firefox =
82+
opts.drivers.firefox.fullURL ||
83+
util.format(
84+
urls.firefox,
85+
opts.drivers.firefox.baseURL,
86+
getFirefoxDriverDirectory(opts.drivers.firefox.version),
87+
getFirefoxDriverName(opts.drivers.firefox.version),
88+
getFirefoxDriverVersionForUrl(opts.drivers.firefox.version),
89+
getFirefoxDriverArchitecture(opts.drivers.firefox.version, opts.drivers.firefox.arch)
90+
);
8391
}
8492
if (opts.drivers.edge) {
85-
downloadUrls.edge = getEdgeDriverUrl(opts.drivers.edge.version);
93+
downloadUrls.edge = opts.drivers.edge.fullURL || getEdgeDriverUrl(opts.drivers.edge.version);
8694
}
8795
if (opts.drivers.chromiumedge) {
8896
await resolveLatestVersion(
8997
opts,
9098
'chromiumedge',
9199
'https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/LATEST_STABLE'
92100
);
93-
downloadUrls.chromiumedge = util.format(
94-
urls.chromiumedge,
95-
opts.drivers.chromiumedge.baseURL,
96-
opts.drivers.chromiumedge.version,
97-
getChromiumEdgeDriverArchitecture(opts.drivers.chromiumedge.arch)
98-
);
101+
downloadUrls.chromiumedge =
102+
opts.drivers.chromiumedge.fullURL ||
103+
util.format(
104+
urls.chromiumedge,
105+
opts.drivers.chromiumedge.baseURL,
106+
opts.drivers.chromiumedge.version,
107+
getChromiumEdgeDriverArchitecture(opts.drivers.chromiumedge.arch)
108+
);
99109
}
100110

101111
return downloadUrls;

lib/install.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ async function install(_opts, _cb) {
9191
const urls = await computeDownloadUrls({
9292
seleniumVersion: opts.version,
9393
seleniumBaseURL: opts.baseURL,
94+
seleniumFullURL: opts.fullURL,
9495
drivers: opts.drivers,
9596
});
9697

test/compute-download-urls-test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ describe('compute-download-urls', () => {
5858

5959
assert.strictEqual(actual.selenium, 'https://localhost/3.0-beta2/selenium-server-standalone-3.0.0-beta2.jar');
6060
});
61+
62+
it('fullURL', async () => {
63+
const actual = await computeDownloadUrls({
64+
seleniumVersion: '4.0.0-alpha-7',
65+
seleniumFullURL:
66+
'https://selenium-release.storage.googleapis.com/4.0-alpha-7/selenium-server-4.0.0-alpha-7.jar',
67+
drivers: {},
68+
});
69+
70+
assert.strictEqual(
71+
actual.selenium,
72+
'https://selenium-release.storage.googleapis.com/4.0-alpha-7/selenium-server-4.0.0-alpha-7.jar'
73+
);
74+
});
6175
});
6276

6377
describe('chrome', () => {
@@ -99,6 +113,19 @@ describe('compute-download-urls', () => {
99113
const actual = await computeDownloadUrls(opts);
100114
assert.strictEqual(actual.chrome, 'https://localhost/2.0/chromedriver_linux64.zip');
101115
});
116+
117+
it('fullURL', async () => {
118+
opts.drivers.chrome = {
119+
fullURL: 'https://chromedriver.storage.googleapis.com/87.0.4280.20/chromedriver_linux64.zip',
120+
version: 'custom',
121+
};
122+
123+
const actual = await computeDownloadUrls(opts);
124+
assert.strictEqual(
125+
actual.chrome,
126+
'https://chromedriver.storage.googleapis.com/87.0.4280.20/chromedriver_linux64.zip'
127+
);
128+
});
102129
});
103130

104131
describe('mac', () => {

0 commit comments

Comments
 (0)