File tree Expand file tree Collapse file tree 6 files changed +61
-35
lines changed
src/Winium.Desktop.Driver Expand file tree Collapse file tree 6 files changed +61
-35
lines changed Original file line number Diff line number Diff line change 8
8
9
9
## v1.6.0
10
10
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
13
12
- Fix throw exceptions in getting some gui element's attributes
14
13
15
14
Original file line number Diff line number Diff line change 1
1
namespace Winium . Desktop . Driver . CommandExecutors
2
2
{
3
+ #region using
4
+
5
+ using Winium . Desktop . Driver . CommonHelpers ;
6
+
7
+ #endregion
8
+
3
9
internal class CloseExecutor : CommandExecutorBase
4
10
{
5
11
#region Methods
6
12
7
13
protected override string DoImpl ( )
8
14
{
9
- if ( ! this . Automator . ActualCapabilities . DebugConnectToRunningApp )
10
- {
11
- if ( ! this . Automator . Application . Close ( ) )
12
- {
13
- this . Automator . Application . Kill ( ) ;
14
- }
15
-
16
- this . Automator . ElementsRegistry . Clear ( ) ;
17
- }
18
-
19
- return this . JsonResponse ( ) ;
15
+ return CommonHelpers . TerminateExcecutor ( this . Automator , this . JsonResponse ( ) ) ;
20
16
}
21
17
22
18
#endregion
Original file line number Diff line number Diff line change @@ -32,17 +32,6 @@ protected override string DoImpl()
32
32
// Gives sometime to load visuals (needed only in case of slow emulation)
33
33
Thread . Sleep ( this . Automator . ActualCapabilities . LaunchDelay ) ;
34
34
35
- // Update running application process pointing to the real process instead of the launcher in such cases
36
- if ( this . Automator . Application . HasExited ( ) )
37
- {
38
- // Add parse process name pass from request
39
- var realProcessName = this . ExecutedCommand . Parameters [ "desiredCapabilities" ] [ "realProcessName" ] ;
40
- // Update launched process by process name if it's exited
41
- if ( realProcessName != null )
42
- {
43
- this . Automator . Application . UpdateProcessByName ( realProcessName . ToString ( ) ) ;
44
- }
45
- }
46
35
return this . JsonResponse ( ResponseStatus . Success , this . Automator . ActualCapabilities ) ;
47
36
}
48
37
Original file line number Diff line number Diff line change 1
1
namespace Winium . Desktop . Driver . CommandExecutors
2
2
{
3
+ #region using
4
+
5
+ using Winium . Desktop . Driver . CommonHelpers ;
6
+
7
+ #endregion
8
+
3
9
internal class QuitExecutor : CommandExecutorBase
4
10
{
5
11
#region Methods
6
12
7
13
protected override string DoImpl ( )
8
14
{
9
- if ( ! this . Automator . ActualCapabilities . DebugConnectToRunningApp )
10
- {
11
- if ( ! this . Automator . Application . Close ( ) )
12
- {
13
- this . Automator . Application . Kill ( ) ;
14
- }
15
-
16
- this . Automator . ElementsRegistry . Clear ( ) ;
17
- }
18
-
19
- return this . JsonResponse ( ) ;
15
+ return CommonHelpers . TerminateExcecutor ( this . Automator , this . JsonResponse ( ) ) ;
20
16
}
21
17
22
18
#endregion
Original file line number Diff line number Diff line change
1
+ namespace Winium . Desktop . Driver . CommonHelpers
2
+ {
3
+ #region using
4
+
5
+ using System . Collections . Generic ;
6
+ using System . Diagnostics ;
7
+
8
+ using Winium . Desktop . Driver . Automator ;
9
+
10
+ #endregion
11
+
12
+ public static class CommonHelpers
13
+ {
14
+ public static string TerminateExcecutor ( object automatorObject , string jsonResponse )
15
+ {
16
+ Automator automator = ( Automator ) automatorObject ;
17
+ if ( ! automator . ActualCapabilities . DebugConnectToRunningApp )
18
+ {
19
+ // If application had exited, find and terminate all children processes
20
+ if ( automator . Application . HasExited ( ) )
21
+ {
22
+ List < Process > children = new List < Process > ( ) ;
23
+ children = automator . Application . GetChildPrecesses ( automator . Application . GetProcessId ( ) ) ;
24
+ foreach ( var child in children )
25
+ {
26
+ if ( ! child . HasExited && ! automator . Application . Close ( child ) )
27
+ {
28
+ automator . Application . Kill ( child ) ;
29
+ }
30
+ }
31
+ }
32
+
33
+ // If application is still running, terminate it as normal case
34
+ else if ( ! automator . Application . Close ( ) )
35
+ {
36
+ automator . Application . Kill ( ) ;
37
+ }
38
+
39
+ automator . ElementsRegistry . Clear ( ) ;
40
+ }
41
+
42
+ return jsonResponse ;
43
+ }
44
+ }
45
+ }
Original file line number Diff line number Diff line change 116
116
<Compile Include =" CommandExecutors\NotImplementedExecutor.cs" />
117
117
<Compile Include =" CommandExecutors\SwitchToWindowExecutor.cs" />
118
118
<Compile Include =" CommandLineOptions.cs" />
119
+ <Compile Include =" CommonHelpers\CommonHelpers.cs" />
119
120
<Compile Include =" ElementsRegistry.cs" />
120
121
<Compile Include =" Extensions\AutomationPropertyHelper.cs" />
121
122
<Compile Include =" Extensions\ByHelper.cs" />
You can’t perform that action at this time.
0 commit comments