diff --git a/lib/commands/context.js b/lib/commands/context.js index f7f0fda2d..ad1a541d9 100644 --- a/lib/commands/context.js +++ b/lib/commands/context.js @@ -9,6 +9,7 @@ const WEBVIEW_WIN = 'WEBVIEW'; const WEBVIEW_BASE = `${WEBVIEW_WIN}_`; const DEFAULT_REMOTE_DEBUGGER_CONNECT_TIMEOUT_MS = 5000; const DEFAULT_LIST_WEB_FRAMES_RETRIES = 20; +const DEFAULT_NATIVE_WINDOW_HANDLE = '1'; const extensions = { @@ -612,6 +613,10 @@ const commands = { * @returns {Promise} */ async setWindow(name, skipReadyCheck) { + if (!this.isWebContext()) { + // https://github.com/appium/appium/issues/20710 + return; + } try { await this.setContext(name, _.noop, skipReadyCheck); } catch (err) { @@ -626,7 +631,8 @@ const commands = { // eslint-disable-next-line require-await async getWindowHandle() { if (!this.isWebContext()) { - throw new errors.NotImplementedError(); + // https://github.com/appium/appium/issues/20710 + return DEFAULT_NATIVE_WINDOW_HANDLE; } if (!this.curContext) { throw new errors.InvalidContextError(); @@ -640,7 +646,8 @@ const commands = { */ async getWindowHandles() { if (!this.isWebContext()) { - throw new errors.NotImplementedError(); + // https://github.com/appium/appium/issues/20710 + return [DEFAULT_NATIVE_WINDOW_HANDLE]; } this.log.debug('Getting list of available window handles'); const contexts = await this.getContextsAndViews(false);