diff --git a/packages/base-driver/lib/basedriver/commands/timeout.ts b/packages/base-driver/lib/basedriver/commands/timeout.ts index 0613081a4..25ca83727 100644 --- a/packages/base-driver/lib/basedriver/commands/timeout.ts +++ b/packages/base-driver/lib/basedriver/commands/timeout.ts @@ -15,24 +15,20 @@ const MIN_TIMEOUT = 0; const TimeoutCommands: ITimeoutCommands = { async timeouts(this: BaseDriver, type, ms, script, pageLoad, implicit) { - if (util.hasValue(type) && util.hasValue(ms)) { - this.log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`); + if (type && util.hasValue(ms)) { + this.log.debug(`Timeout arguments: ${JSON.stringify({type, ms})}}`); switch (type) { case 'command': - await this.newCommandTimeout(ms); - return; + return void (await this.newCommandTimeout(ms)); case 'implicit': - await this.implicitWaitMJSONWP(ms); - return; + return void (await this.implicitWaitW3C(ms)); case 'page load': - await this.pageLoadTimeoutMJSONWP(ms); - return; + return void (await this.pageLoadTimeoutW3C(ms)); case 'script': - await this.scriptTimeoutMJSONWP(ms); - return; + return void (await this.scriptTimeoutW3C(ms)); default: - throw new Error(`'${type}' type is not supported for MJSONWP timeout`); + throw new Error(`'${type}' type is not supported for the timeout API`); } } @@ -63,47 +59,28 @@ const TimeoutCommands: ITimeoutCommands = { }, // implicit - async implicitWaitW3C(this: BaseDriver, ms) { - await this.implicitWait(ms); - }, - - async implicitWaitMJSONWP(this: BaseDriver, ms) { - await this.implicitWait(ms); - }, - - async implicitWait(this: BaseDriver, ms) { + async implicitWaitW3C(this: BaseDriver, ms: number) { this.setImplicitWait(this.parseTimeoutArgument(ms)); }, // pageLoad // eslint-disable-next-line @typescript-eslint/no-unused-vars - async pageLoadTimeoutW3C(this: BaseDriver, ms) { - throw new errors.NotImplementedError('Not implemented yet for pageLoad.'); - }, - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async pageLoadTimeoutMJSONWP(this: BaseDriver, ms) { + async pageLoadTimeoutW3C(this: BaseDriver, ms: number) { throw new errors.NotImplementedError('Not implemented yet for pageLoad.'); }, // script // eslint-disable-next-line @typescript-eslint/no-unused-vars - async scriptTimeoutW3C(this: BaseDriver, ms) { - throw new errors.NotImplementedError('Not implemented yet for script.'); - }, - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async scriptTimeoutMJSONWP(this: BaseDriver, ms) { + async scriptTimeoutW3C(this: BaseDriver, ms: number) { throw new errors.NotImplementedError('Not implemented yet for script.'); }, // command - async newCommandTimeout(this: BaseDriver, ms) { + async newCommandTimeout(this: BaseDriver, ms: number) { this.setNewCommandTimeout(this.parseTimeoutArgument(ms)); }, setImplicitWait(this: BaseDriver, ms: number) { - this.implicitWaitMs = ms; this.log.debug(`Set implicit wait to ${ms}ms`); if (this.managedDrivers && this.managedDrivers.length) { diff --git a/packages/base-driver/test/unit/basedriver/timeout.spec.js b/packages/base-driver/test/unit/basedriver/timeout.spec.js index 847ed228c..8e343c4be 100644 --- a/packages/base-driver/test/unit/basedriver/timeout.spec.js +++ b/packages/base-driver/test/unit/basedriver/timeout.spec.js @@ -71,26 +71,6 @@ describe('timeout', function () { }); }); }); - describe('implicitWait', function () { - it('should call setImplicitWait when given an integer', async function () { - await driver.implicitWait(42); - implicitWaitSpy.calledOnce.should.be.true; - implicitWaitSpy.firstCall.args[0].should.equal(42); - driver.implicitWaitMs.should.eql(42); - }); - it('should call setImplicitWait when given a string', async function () { - await driver.implicitWait('42'); - implicitWaitSpy.calledOnce.should.be.true; - implicitWaitSpy.firstCall.args[0].should.equal(42); - driver.implicitWaitMs.should.eql(42); - }); - it('should throw an error if something random is sent', async function () { - await driver.implicitWait('howdy').should.eventually.be.rejected; - }); - it('should throw an error if timeout is negative', async function () { - await driver.implicitWait(-42).should.eventually.be.rejected; - }); - }); describe('set implicit wait', function () { it('should set the implicit wait with an integer', function () { diff --git a/packages/driver-test-support/lib/unit-suite.js b/packages/driver-test-support/lib/unit-suite.js index 1a336978d..b0931a204 100644 --- a/packages/driver-test-support/lib/unit-suite.js +++ b/packages/driver-test-support/lib/unit-suite.js @@ -337,7 +337,6 @@ export function driverUnitTestSuite( await d.deleteSession(); }); it('should get timeouts that we set', async function () { - // @ts-expect-error await d.timeouts(undefined, undefined, undefined, undefined, 1000); await d.getTimeouts().should.eventually.have.property('implicit', 1000); await d.timeouts('command', 2000); @@ -345,7 +344,6 @@ export function driverUnitTestSuite( implicit: 1000, command: 2000, }); - // @ts-expect-error await d.timeouts(undefined, undefined, undefined, undefined, 3000); await d.getTimeouts().should.eventually.deep.equal({ implicit: 3000, diff --git a/packages/types/lib/driver.ts b/packages/types/lib/driver.ts index e0343681f..21c549aa0 100644 --- a/packages/types/lib/driver.ts +++ b/packages/types/lib/driver.ts @@ -35,8 +35,8 @@ export interface ITimeoutCommands { * @param implicit - the number in ms for the implicit wait timeout, used for the W3C command */ timeouts( - type: string, - ms: number | string, + type?: string, + ms?: number | string, script?: number, pageLoad?: number, implicit?: number | string, @@ -49,16 +49,6 @@ export interface ITimeoutCommands { */ setNewCommandTimeout(ms: number): void; - /** - * Set the implicit wait timeout - * - * @param ms - the timeout in ms - * - * @deprecated Use `timeouts` instead - * - */ - implicitWait(ms: number | string): Promise; - /** * A helper method (not a command) used to set the implicit wait value * @@ -90,14 +80,6 @@ export interface ITimeoutCommands { */ implicitWaitW3C(ms: number): Promise; - /** - * Set the implicit wait value that was sent in via the JSONWP - * - * @param ms - the timeout in ms - * @deprecated - */ - implicitWaitMJSONWP(ms: number): Promise; - /** * Set the page load timeout value that was sent in via the W3C protocol * @@ -105,14 +87,6 @@ export interface ITimeoutCommands { */ pageLoadTimeoutW3C(ms: number): Promise; - /** - * Set the page load timeout value that was sent in via the JSONWP - * - * @param ms - the timeout in ms - * @deprecated - */ - pageLoadTimeoutMJSONWP(ms: number): Promise; - /** * Set the script timeout value that was sent in via the W3C protocol * @@ -120,14 +94,6 @@ export interface ITimeoutCommands { */ scriptTimeoutW3C(ms: number): Promise; - /** - * Set the script timeout value that was sent in via the JSONWP - * - * @param ms - the timeout in ms - * @deprecated - */ - scriptTimeoutMJSONWP(ms: number): Promise; - /** * Set Appium's new command timeout *