Skip to content

Commit

Permalink
feat: Return default native window handle in native context (#2491)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Nov 12, 2024
1 parent 5f39340 commit 0a545e0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/commands/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -612,6 +613,10 @@ const commands = {
* @returns {Promise<void>}
*/
async setWindow(name, skipReadyCheck) {
if (!this.isWebContext()) {
// https://github.com/appium/appium/issues/20710
return;
}
try {
await this.setContext(name, _.noop, skipReadyCheck);
} catch (err) {
Expand All @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 0a545e0

Please sign in to comment.