diff --git a/lib/commands/general.js b/lib/commands/general.js index d8f678b61..018eadf0b 100644 --- a/lib/commands/general.js +++ b/lib/commands/general.js @@ -202,15 +202,6 @@ const GeneralMixin = { ); }, - /** - * Overriding appium-android-driver's wrapBootstrapDisconnect, - * unlike in appium-android-driver avoiding adb restarting as it intern - * kills UiAutomator2 server running in the device. - **/ - async wrapBootstrapDisconnect(wrapped) { - await wrapped(); - }, - // Stop proxying to any Chromedriver and redirect to uiautomator2 suspendChromedriverProxy() { this.chromedriver = undefined; diff --git a/lib/commands/mixins.ts b/lib/commands/mixins.ts index 88103f886..7c2d631d0 100644 --- a/lib/commands/mixins.ts +++ b/lib/commands/mixins.ts @@ -1,6 +1,9 @@ /** * @module - * @privateRemarks These mixins are kind of a mishmash of stuff from `appium-android-driver`, unique things, and stuff from `ExternalDriver`. Ideally, we should be pulling the method definitions right out of `ExternalDriver` whenever possible. Also note that the mixins contain _more stuff than just commands or execute methods_. + * @privateRemarks These mixins are kind of a mishmash of stuff from `appium-android-driver`, + * @privateRemarks unique things, and stuff from `ExternalDriver`. Ideally, we should be pulling the method + * @privateRemarks definitions right out of `ExternalDriver` whenever possible. Also note that the mixins + * @privateRemarks contain _more stuff than just commands or execute methods_. */ import type {Element, ExternalDriver, StringRecord} from '@appium/types'; @@ -87,7 +90,6 @@ export type UIA2GeneralMixin = UIA2Mixin< | 'getWindowSize' | 'getWindowRect' | 'setUrl' - | 'wrapBootstrapDisconnect' | 'keyevent' | 'execute' | 'executeMobile' diff --git a/lib/driver.ts b/lib/driver.ts index 2d39645bf..617bda44c 100644 --- a/lib/driver.ts +++ b/lib/driver.ts @@ -27,7 +27,6 @@ import uiautomator2Helpers from './helpers'; import {newMethodMap} from './method-map'; import type { Uiautomator2Settings, - Uiautomator2CreateResult, Uiautomator2DeviceDetails, Uiautomator2DeviceInfo, Uiautomator2DriverCaps, @@ -163,14 +162,12 @@ const CHROME_NO_PROXY: RouteMatcher[] = [ const MEMOIZED_FUNCTIONS = ['getStatusBarHeight', 'getDevicePixelRatio'] as const; class AndroidUiautomator2Driver - extends AndroidDriver + extends AndroidDriver implements ExternalDriver< Uiautomator2Constraints, string, - StringRecord, - Uiautomator2Settings, - Uiautomator2CreateResult + StringRecord > { static newMethodMap = newMethodMap; @@ -236,12 +233,12 @@ class AndroidUiautomator2Driver ); } - override async createSession( + async createSession( w3cCaps1: W3CUiautomator2DriverCaps, w3cCaps2?: W3CUiautomator2DriverCaps, w3cCaps3?: W3CUiautomator2DriverCaps, driverData?: DriverData[] - ): Promise { + ): Promise { try { // TODO handle otherSessionData for multiple sessions const [sessionId, caps] = (await BaseDriver.prototype.createSession.call( @@ -340,11 +337,7 @@ class AndroidUiautomator2Driver return {...sessionData, ...uia2Data}; } - override isEmulator() { - return helpers.isEmulator(this.adb, this.opts); - } - - override setAvdFromCapabilities(caps: Uiautomator2StartSessionOpts) { + setAvdFromCapabilities(caps: Uiautomator2StartSessionOpts) { if (this.opts.avd) { this.log.info('avd name defined, ignoring device name and platform version'); } else { @@ -737,7 +730,7 @@ class AndroidUiautomator2Driver }); } - override async deleteSession() { + async deleteSession() { this.log.debug('Deleting UiAutomator2 session'); const screenRecordingStopTasks = [ @@ -871,7 +864,7 @@ class AndroidUiautomator2Driver await BaseDriver.prototype.deleteSession.call(this); } - override async checkAppPresent() { + async checkAppPresent() { this.log.debug('Checking whether app is actually present'); if (!(await fs.exists(this.opts.app))) { this.log.errorAndThrow(`Could not find app apk at '${this.opts.app}'`); @@ -879,36 +872,24 @@ class AndroidUiautomator2Driver } } - override async onSettingsUpdate() { + async onSettingsUpdate() { // intentionally do nothing here, since commands.updateSettings proxies // settings to the uiauto2 server already } - // Need to override android-driver's version of this since we don't actually - // have a bootstrap; instead we just restart adb and re-forward the UiAutomator2 - // port - override async wrapBootstrapDisconnect(wrapped: () => Promise) { - await wrapped(); - this.adb!.restart(); - await this.allocateSystemPort(); - await this.allocateMjpegServerPort(); - } - - override proxyActive(sessionId: string) { - BaseDriver.prototype.proxyActive.call(this, sessionId); - + // eslint-disable-next-line @typescript-eslint/no-unused-vars + proxyActive(sessionId: string) { // we always have an active proxy to the UiAutomator2 server return true; } - override canProxy(sessionId: string) { - BaseDriver.prototype.canProxy.call(this, sessionId); - + // eslint-disable-next-line @typescript-eslint/no-unused-vars + canProxy(sessionId: string) { // we can always proxy to the uiautomator2 server return true; } - override getProxyAvoidList() { + getProxyAvoidList() { // we are maintaining two sets of NO_PROXY lists, one for chromedriver(CHROME_NO_PROXY) // and one for uiautomator2(NO_PROXY), based on current context will return related NO_PROXY list if (util.hasValue(this.chromedriver)) { @@ -927,10 +908,6 @@ class AndroidUiautomator2Driver return this.jwpProxyAvoid; } - get isChromeSession() { - return helpers.isChromeBrowser(this.opts.browserName); - } - async updateSettings(settings: Uiautomator2Settings) { await this.settings.update(settings); await this.uiautomator2!.jwproxy.command('/appium/settings', 'POST', {settings}); @@ -942,7 +919,7 @@ class AndroidUiautomator2Driver '/appium/settings', 'GET' )) as Partial; - return {...driverSettings, ...serverSettings}; + return {...driverSettings, ...serverSettings} as any; } } diff --git a/lib/types.ts b/lib/types.ts index a15797400..ce80765d7 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,5 +1,4 @@ import type {DriverCaps, DriverOpts, W3CDriverCaps} from '@appium/types'; -import type {AndroidSettings} from 'appium-android-driver'; import type {EmptyObject} from 'type-fest'; import type {RelativeRect} from './commands/types'; import type {Uiautomator2Constraints} from './constraints'; @@ -52,8 +51,7 @@ export interface Uiautomator2SessionCaps Uiautomator2DeviceInfo, Uiautomator2DeviceDetails {} -export type Uiautomator2CreateResult = [string, Uiautomator2SessionCaps]; - -export interface Uiautomator2Settings extends AndroidSettings { +export interface Uiautomator2Settings { + ignoreUnimportantViews: boolean; allowInvisibleElements: boolean; } diff --git a/package.json b/package.json index 43e75dedd..d7731f656 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ }, "dependencies": { "appium-adb": "^9.14.12", - "appium-android-driver": "^6.0.0", + "appium-android-driver": "^7.0.1", "appium-chromedriver": "^5.6.5", "appium-uiautomator2-server": "^5.12.2", "asyncbox": "^2.3.1", diff --git a/tsconfig.json b/tsconfig.json index 84b0b4a37..7a1536271 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "outDir": "build", "strict": false, "checkJs": true, - "types": ["node", "mocha", "sinon-chai", "chai-as-promised"] + "types": ["node"] }, "include": ["lib", "index.js"] }