Skip to content

Commit 57fbea6

Browse files
committed
added try-catch for focusing window on screenshot
1 parent 5a5941a commit 57fbea6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/commands/app.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@ export async function getPageSource(this: NovaWindowsDriver): Promise<string> {
4747
}
4848

4949
export async function getScreenshot(this: NovaWindowsDriver): Promise<string> {
50-
// TODO: check if it causes problem if child window is opened
5150
const automationRootId = await this.sendPowerShellCommand(AutomationElement.automationRoot.buildCommand());
52-
await this.focusElement({
53-
[W3C_ELEMENT_KEY]: automationRootId.trim(),
54-
} satisfies Element);
51+
52+
if (this.caps.app && this.caps.app.toLowerCase() !== 'root') {
53+
try {
54+
await this.focusElement({
55+
[W3C_ELEMENT_KEY]: automationRootId.trim(),
56+
} satisfies Element);
57+
} catch {
58+
// noop
59+
}
60+
}
5561

5662
return await this.sendPowerShellCommand(GET_SCREENSHOT_COMMAND);
5763
}

0 commit comments

Comments
 (0)