Skip to content

Commit

Permalink
Add exception for opera driver
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Jan 23, 2025
1 parent 268a5fc commit a5608ad
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/chromedriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export class Chromedriver extends events.EventEmitter {
// Store the running driver version
/** @type {string|null} */
this._driverVersion = null;
/** @type {Record<string, any> | null} */
this._onlineStatus = null;
}

get log() {
Expand Down Expand Up @@ -525,6 +527,16 @@ export class Chromedriver extends events.EventEmitter {
* @returns {keyof PROTOCOLS}
*/
syncProtocol() {
if (_.includes(this._onlineStatus?.message, 'OperaDriver')) {
this.log.info(
`OperaDriver is known to not support ${PROTOCOLS.W3C} protocol, ` +
`defaulting to ${PROTOCOLS.MJSONWP}. ` +
`See https://github.com/operasoftware/operachromiumdriver/issues/88`
);
this._desiredProtocol = PROTOCOLS.MJSONWP;
return this._desiredProtocol;
}

if (this.driverVersion) {
const coercedVersion = semver.coerce(this.driverVersion);
if (!coercedVersion || coercedVersion.major < MIN_CD_VERSION_WITH_W3C_SUPPORT) {
Expand Down Expand Up @@ -630,6 +642,7 @@ export class Chromedriver extends events.EventEmitter {
this.proc.once('exit', (code, signal) => {
this._driverVersion = null;
this._desiredProtocol = null;
this._onlineStatus = null;
processIsAlive = false;
if (
this.state !== Chromedriver.STATE_STOPPED &&
Expand Down Expand Up @@ -710,6 +723,7 @@ export class Chromedriver extends events.EventEmitter {
if (!_.isPlainObject(status) || !status.ready) {
throw new Error(`The response to the /status API is not valid: ${JSON.stringify(status)}`);
}
this._onlineStatus = status;
const versionMatch = VERSION_PATTERN.exec(status.build?.version ?? '');
if (versionMatch) {
this._driverVersion = versionMatch[1];
Expand Down

0 comments on commit a5608ad

Please sign in to comment.