File tree Expand file tree Collapse file tree 3 files changed +55
-4
lines changed
src/Winium.Desktop.Driver/CommandExecutors Expand file tree Collapse file tree 3 files changed +55
-4
lines changed Original file line number Diff line number Diff line change 88
99## v1.6.0
1010
11- - Allow switching process name to ` realProcessName ` for an apps starting
12- with a launcher. That can fix exception Process Not Found in close/quit function
11+ - Fix exception Process Not Found in close/quit function
1312- Fix throw exceptions in getting some gui element's attributes
1413
1514
Original file line number Diff line number Diff line change 11namespace Winium . Desktop . Driver . CommandExecutors
22{
3+ #region using
4+
5+ using System . Collections . Generic ;
6+ using System . Diagnostics ;
7+
8+ #endregion
9+
310 internal class CloseExecutor : CommandExecutorBase
411 {
512 #region Methods
@@ -8,7 +15,26 @@ protected override string DoImpl()
815 {
916 if ( ! this . Automator . ActualCapabilities . DebugConnectToRunningApp )
1017 {
11- if ( ! this . Automator . Application . Close ( ) )
18+ // If application had exited, find and terminate all children processes
19+ if ( this . Automator . Application . HasExited ( ) )
20+ {
21+ List < Process > children = new List < Process > ( ) ;
22+ children = this . Automator . Application . GetChildPrecesses ( this . Automator . Application . GetProcessId ( ) ) ;
23+ if ( children . Count == 0 )
24+ {
25+ children = this . Automator . Application . GetAllPrecessesByName ( this . Automator . Application . GetProcessName ( ) ) ;
26+ }
27+ foreach ( var child in children )
28+ {
29+ if ( ! child . HasExited && ! this . Automator . Application . Close ( child ) )
30+ {
31+ this . Automator . Application . Kill ( child ) ;
32+ }
33+ }
34+ }
35+
36+ // If application is still running, terminate it as normal case
37+ else if ( ! this . Automator . Application . Close ( ) )
1238 {
1339 this . Automator . Application . Kill ( ) ;
1440 }
Original file line number Diff line number Diff line change 11namespace Winium . Desktop . Driver . CommandExecutors
22{
3+ #region using
4+
5+ using System . Collections . Generic ;
6+ using System . Diagnostics ;
7+
8+ #endregion
9+
310 internal class QuitExecutor : CommandExecutorBase
411 {
512 #region Methods
@@ -8,7 +15,26 @@ protected override string DoImpl()
815 {
916 if ( ! this . Automator . ActualCapabilities . DebugConnectToRunningApp )
1017 {
11- if ( ! this . Automator . Application . Close ( ) )
18+ // If application had exited, find and terminate all children processes
19+ if ( this . Automator . Application . HasExited ( ) )
20+ {
21+ List < Process > children = new List < Process > ( ) ;
22+ children = this . Automator . Application . GetChildPrecesses ( this . Automator . Application . GetProcessId ( ) ) ;
23+ if ( children . Count == 0 )
24+ {
25+ children = this . Automator . Application . GetAllPrecessesByName ( this . Automator . Application . GetProcessName ( ) ) ;
26+ }
27+ foreach ( var child in children )
28+ {
29+ if ( ! child . HasExited && ! this . Automator . Application . Close ( child ) )
30+ {
31+ this . Automator . Application . Kill ( child ) ;
32+ }
33+ }
34+ }
35+
36+ // If application is still running, terminate it as normal case
37+ else if ( ! this . Automator . Application . Close ( ) )
1238 {
1339 this . Automator . Application . Kill ( ) ;
1440 }
You can’t perform that action at this time.
0 commit comments