Skip to content

Commit ebf7f3a

Browse files
authored
Fix selenium-webdriver patch versions dowload for v4 (#607)
1 parent c653a0e commit ebf7f3a

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

lib/compute-download-urls.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ async function computeDownloadUrls(opts) {
4444
util.format(
4545
isSelenium4(opts.seleniumVersion) ? urls.seleniumV4 : urls.selenium,
4646
opts.seleniumBaseURL,
47-
`selenium-${opts.seleniumVersion}`,
47+
`selenium-${
48+
isSelenium4(opts.seleniumVersion) ? getVersionWithZeroedPatchPart(opts.seleniumVersion) : opts.seleniumVersion
49+
}`,
4850
opts.seleniumVersion
4951
),
5052
};
@@ -253,3 +255,13 @@ async function getLatestGeckodriver(opts, browserDriver, url) {
253255
return true;
254256
}
255257
}
258+
259+
function getVersionWithZeroedPatchPart(fullVersion) {
260+
if (!/^\d+\.\d+\.\d+$/i.test(fullVersion)) {
261+
// If version longer than just 3 numbers, like '4.0.0-beta-1', do nothing
262+
return fullVersion;
263+
}
264+
// else make version patch part zero: '4.1.1' => '4.1.0'
265+
const [major, minor] = fullVersion.split('.');
266+
return `${major}.${minor}.0`;
267+
}

test/compute-download-urls-test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,36 @@ describe('compute-download-urls', () => {
6262
);
6363
});
6464

65+
it('version 4 basic', async () => {
66+
const actual = await computeDownloadUrls({
67+
seleniumVersion: '4.1.0',
68+
seleniumBaseURL: 'https://localhost',
69+
drivers: {},
70+
});
71+
72+
assert.strictEqual(actual.selenium, 'https://localhost/selenium-4.1.0/selenium-server-4.1.0.jar');
73+
});
74+
75+
it('version 4 with patch', async () => {
76+
const actual = await computeDownloadUrls({
77+
seleniumVersion: '4.1.1',
78+
seleniumBaseURL: 'https://localhost',
79+
drivers: {},
80+
});
81+
82+
assert.strictEqual(actual.selenium, 'https://localhost/selenium-4.1.0/selenium-server-4.1.1.jar');
83+
});
84+
85+
it('version 4 with beta string', async () => {
86+
const actual = await computeDownloadUrls({
87+
seleniumVersion: '4.0.0-beta-3',
88+
seleniumBaseURL: 'https://localhost',
89+
drivers: {},
90+
});
91+
92+
assert.strictEqual(actual.selenium, 'https://localhost/selenium-4.0.0-beta-3/selenium-server-4.0.0-beta-3.jar');
93+
});
94+
6595
it('fullURL', async () => {
6696
const actual = await computeDownloadUrls({
6797
seleniumVersion: '4.0.0-alpha-7',

0 commit comments

Comments
 (0)