Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Return default window handle in native context #2491

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading