Skip to content

Commit

Permalink
Chrome drivers 115+ (#105)
Browse files Browse the repository at this point in the history
Fixes #103.
  • Loading branch information
gitgrimbo authored Oct 31, 2023
1 parent 1b699bf commit 419149c
Showing 1 changed file with 52 additions and 16 deletions.
68 changes: 52 additions & 16 deletions src/SeleniumTunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,13 @@ interface ChromeProperties {

type ChromeOptions = Partial<ChromeProperties>;

function versionGreaterThan(versionStr: String, version: number[]) {
const parts = String(versionStr).split('.').map(Number);
return version.some(function (part, i) {
return parts[i] > part;
});
}

class ChromeConfig
extends Config<ChromeOptions>
implements ChromeProperties, DriverFile
Expand All @@ -456,19 +463,29 @@ class ChromeConfig
baseUrl!: string;
platform!: string;
version!: string;
useNewDriverLocation!: boolean;

constructor(options: ChromeOptions) {
super(
Object.assign(
{
arch: process.arch,
baseUrl: webdrivers.chrome.baseUrl,
platform: process.platform,
version: webdrivers.chrome.latest,
},
options
)
const opts = Object.assign(
{
arch: process.arch,
baseUrl: webdrivers.chrome.baseUrl,
platform: process.platform,
version: webdrivers.chrome.latest,
},
options
);

const useNewDriverLocation = versionGreaterThan(opts.version, [114]);
if (useNewDriverLocation && opts.baseUrl == webdrivers.chrome.baseUrl) {
// A 'new' chrome driver has been requested, but we're being asked to configure using the old default baseUrl.
// Therefore use new baseUrl for new driver instead.
opts.baseUrl =
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing';
}

super(Object.assign(opts, options));
this.useNewDriverLocation = useNewDriverLocation;
}

get artifact() {
Expand All @@ -482,22 +499,41 @@ class ChromeConfig
});
platform = isGreater ? 'mac64' : 'mac32';
}
return format('chromedriver_%s.zip', platform);

return this.useNewDriverLocation
? format('chromedriver-%s.zip', platform)
: format('chromedriver_%s.zip', platform);
}

get directory() {
return join(this.version, this.arch);
}

get url() {
return format('%s/%s/%s', this.baseUrl, this.version, this.artifact);
return this.useNewDriverLocation
? format(
'%s/%s/%s/%s',
this.baseUrl,
this.version,
this.platform,
this.artifact
)
: format('%s/%s/%s', this.baseUrl, this.version, this.artifact);
}

get executable() {
return join(
this.directory,
this.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver'
);
return this.useNewDriverLocation
? join(
this.directory,
format('chromedriver-%s', this.platform),
this.platform === 'win32' || this.platform === 'win64'
? 'chromedriver.exe'
: 'chromedriver'
)
: join(
this.directory,
this.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver'
);
}

get seleniumProperty() {
Expand Down

0 comments on commit 419149c

Please sign in to comment.