mirror of
https://github.com/appium/appium.git
synced 2026-02-21 10:49:52 -06:00
chore: Remove deprecated JWP timeout handlers (#21207)
This commit is contained in:
@@ -15,24 +15,20 @@ const MIN_TIMEOUT = 0;
|
||||
|
||||
const TimeoutCommands: ITimeoutCommands = {
|
||||
async timeouts<C extends Constraints>(this: BaseDriver<C>, 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<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
await this.implicitWait(ms);
|
||||
},
|
||||
|
||||
async implicitWaitMJSONWP<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
await this.implicitWait(ms);
|
||||
},
|
||||
|
||||
async implicitWait<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
async implicitWaitW3C<C extends Constraints>(this: BaseDriver<C>, ms: number) {
|
||||
this.setImplicitWait(this.parseTimeoutArgument(ms));
|
||||
},
|
||||
|
||||
// pageLoad
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async pageLoadTimeoutW3C<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
|
||||
},
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async pageLoadTimeoutMJSONWP<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
async pageLoadTimeoutW3C<C extends Constraints>(this: BaseDriver<C>, ms: number) {
|
||||
throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
|
||||
},
|
||||
|
||||
// script
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async scriptTimeoutW3C<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
throw new errors.NotImplementedError('Not implemented yet for script.');
|
||||
},
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async scriptTimeoutMJSONWP<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
async scriptTimeoutW3C<C extends Constraints>(this: BaseDriver<C>, ms: number) {
|
||||
throw new errors.NotImplementedError('Not implemented yet for script.');
|
||||
},
|
||||
|
||||
// command
|
||||
async newCommandTimeout<C extends Constraints>(this: BaseDriver<C>, ms) {
|
||||
async newCommandTimeout<C extends Constraints>(this: BaseDriver<C>, ms: number) {
|
||||
this.setNewCommandTimeout(this.parseTimeoutArgument(ms));
|
||||
},
|
||||
|
||||
setImplicitWait<C extends Constraints>(this: BaseDriver<C>, ms: number) {
|
||||
|
||||
this.implicitWaitMs = ms;
|
||||
this.log.debug(`Set implicit wait to ${ms}ms`);
|
||||
if (this.managedDrivers && this.managedDrivers.length) {
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<void>;
|
||||
|
||||
/**
|
||||
* A helper method (not a command) used to set the implicit wait value
|
||||
*
|
||||
@@ -90,14 +80,6 @@ export interface ITimeoutCommands {
|
||||
*/
|
||||
implicitWaitW3C(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Set the implicit wait value that was sent in via the JSONWP
|
||||
*
|
||||
* @param ms - the timeout in ms
|
||||
* @deprecated
|
||||
*/
|
||||
implicitWaitMJSONWP(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* Set the page load timeout value that was sent in via the JSONWP
|
||||
*
|
||||
* @param ms - the timeout in ms
|
||||
* @deprecated
|
||||
*/
|
||||
pageLoadTimeoutMJSONWP(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Set the script timeout value that was sent in via the W3C protocol
|
||||
*
|
||||
@@ -120,14 +94,6 @@ export interface ITimeoutCommands {
|
||||
*/
|
||||
scriptTimeoutW3C(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Set the script timeout value that was sent in via the JSONWP
|
||||
*
|
||||
* @param ms - the timeout in ms
|
||||
* @deprecated
|
||||
*/
|
||||
scriptTimeoutMJSONWP(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Set Appium's new command timeout
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user