|
1 | | -import { ChildProcessWithoutNullStreams } from 'node:child_process'; |
2 | 1 | import { BaseDriver, W3C_ELEMENT_KEY, errors } from '@appium/base-driver'; |
3 | 2 | import { system } from 'appium/support'; |
| 3 | +import { ChildProcessWithoutNullStreams } from 'node:child_process'; |
| 4 | +import type { ScreenRecorder } from './commands/screen-recorder'; |
4 | 5 | import commands from './commands'; |
5 | 6 | import { |
6 | | - UI_AUTOMATION_DRIVER_CONSTRAINTS, |
7 | | - NovaWindowsDriverConstraints |
| 7 | + NovaWindowsDriverConstraints, |
| 8 | + UI_AUTOMATION_DRIVER_CONSTRAINTS |
8 | 9 | } from './constraints'; |
9 | 10 | import { |
10 | | - assertSupportedEasingFunction |
11 | | -} from './util'; |
12 | | -import { |
13 | | - Condition, |
14 | | - PropertyCondition, |
15 | 11 | AutomationElement, |
| 12 | + Condition, |
16 | 13 | FoundAutomationElement, |
17 | | - TreeScope, |
18 | | - Property, |
19 | | - convertStringToCondition, |
20 | | - PSString, |
21 | 14 | PSControlType, |
22 | 15 | PSInt32Array, |
| 16 | + PSString, |
| 17 | + Property, |
| 18 | + PropertyCondition, |
| 19 | + TreeScope, |
| 20 | + convertStringToCondition, |
23 | 21 | } from './powershell'; |
24 | | -import { xpathToElIdOrIds } from './xpath'; |
| 22 | +import { |
| 23 | + assertSupportedEasingFunction |
| 24 | +} from './util'; |
25 | 25 | import { setDpiAwareness } from './winapi/user32'; |
| 26 | +import { xpathToElIdOrIds } from './xpath'; |
26 | 27 |
|
27 | 28 | import type { |
28 | 29 | DefaultCreateSessionResult, |
@@ -66,8 +67,7 @@ export class NovaWindowsDriver extends BaseDriver<NovaWindowsDriverConstraints, |
66 | 67 | meta: false, |
67 | 68 | shift: false, |
68 | 69 | }; |
69 | | - recordingProcess?: ChildProcessWithoutNullStreams; |
70 | | - recordingOutputPath?: string; |
| 70 | + _screenRecorder: ScreenRecorder | null = null; |
71 | 71 |
|
72 | 72 | constructor(opts: InitialOpts = {} as InitialOpts, shouldValidateCaps = true) { |
73 | 73 | super(opts, shouldValidateCaps); |
@@ -199,15 +199,24 @@ export class NovaWindowsDriver extends BaseDriver<NovaWindowsDriverConstraints, |
199 | 199 |
|
200 | 200 | if (this.caps.shouldCloseApp && this.caps.app && this.caps.app.toLowerCase() !== 'root') { |
201 | 201 | try { |
202 | | - const result = await this.sendPowerShellCommand(AutomationElement.automationRoot.buildCommand()); |
203 | | - const elementId = result.split('\n').map((id) => id.trim()).filter(Boolean)[0]; |
204 | | - if (elementId) { |
205 | | - await this.sendPowerShellCommand(new FoundAutomationElement(elementId).buildCloseCommand()); |
| 202 | + if (this.caps['ms:forcequit'] === true) { |
| 203 | + await this.sendPowerShellCommand(/* ps1 */ ` |
| 204 | + if ($null -ne $rootElement) { |
| 205 | + $processId = $rootElement.Current.ProcessId |
| 206 | + Stop-Process -Id $processId -Force -ErrorAction SilentlyContinue |
| 207 | + } |
| 208 | + `); |
| 209 | + } else { |
| 210 | + const result = await this.sendPowerShellCommand(AutomationElement.automationRoot.buildCommand()); |
| 211 | + const elementId = result.split('\n').map((id) => id.trim()).filter(Boolean)[0]; |
| 212 | + if (elementId) { |
| 213 | + await this.sendPowerShellCommand(new FoundAutomationElement(elementId).buildCloseCommand()); |
| 214 | + } |
206 | 215 | } |
207 | 216 | } catch { |
208 | 217 | // noop |
209 | 218 | } |
210 | | - } // change to close the whole process, not only the window |
| 219 | + } |
211 | 220 | await this.terminatePowerShellSession(); |
212 | 221 |
|
213 | 222 | if (this.caps.postrun) { |
|
0 commit comments