@@ -18,9 +18,9 @@ public class WinAppDriver: WebDriver {
18
18
public static let defaultStartWaitTime : TimeInterval = 1.0
19
19
20
20
private let httpWebDriver : HTTPWebDriver
21
- private let processTree : Win32ProcessTree ?
21
+ private var processTree : Win32ProcessTree ?
22
22
/// The write end of a pipe that is connected to the child process's stdin.
23
- private let childStdinHandle : HANDLE ?
23
+ private var childStdinHandle : HANDLE ?
24
24
25
25
private init (
26
26
httpWebDriver: HTTPWebDriver ,
@@ -115,16 +115,7 @@ public class WinAppDriver: WebDriver {
115
115
}
116
116
117
117
deinit {
118
- if let processTree {
119
- do {
120
- try processTree. terminate ( waitTime: TimeInterval . infinity)
121
- } catch {
122
- assertionFailure ( " WinAppDriver did not terminate within the expected time: \( error) . " )
123
- }
124
- }
125
- if let childStdinHandle {
126
- CloseHandle ( childStdinHandle)
127
- }
118
+ try ? close ( ) // Call close() directly to handle errors.
128
119
}
129
120
130
121
@discardableResult
@@ -135,4 +126,16 @@ public class WinAppDriver: WebDriver {
135
126
public func isInconclusiveInteraction( error: ErrorResponse . Status ) -> Bool {
136
127
error == . winAppDriver_elementNotInteractable || httpWebDriver. isInconclusiveInteraction ( error: error)
137
128
}
129
+
130
+ public func close( ) throws {
131
+ if let childStdinHandle {
132
+ CloseHandle ( childStdinHandle)
133
+ self . childStdinHandle = nil
134
+ }
135
+
136
+ if let processTree {
137
+ try processTree. terminate ( waitTime: TimeInterval . infinity)
138
+ self . processTree = nil
139
+ }
140
+ }
138
141
}
0 commit comments