Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 4d05ce0

Browse files
committed
Merge pull request #47 from groupon/kill_firefox_fix
Fixing a bug where firefox was not being killed on windows, also refacto...
2 parents 8568406 + 18a694b commit 4d05ce0

File tree

7 files changed

+31
-106
lines changed

7 files changed

+31
-106
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
1.5.1 - [BUG] Firefox on windows was not getting terminated with /kill_firefox command
12
1.5.0 - Automatically record video of a running test
23
- Daily rolling logs for grid extras
34
- Adding /kill_safari end point to kill instance of Safari Browser

SeleniumGridExtras/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.groupon.selenium-grid-extras</groupId>
88
<artifactId>SeleniumGridExtras</artifactId>
9-
<version>1.5.0-SNAPSHOT</version>
9+
<version>1.5.1-SNAPSHOT</version>
1010

1111
<repositories>
1212
<repository>

SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllByName.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import com.google.gson.JsonObject;
4343

44+
import com.groupon.seleniumgridextras.ExecuteCommand;
4445
import com.groupon.seleniumgridextras.config.RuntimeConfig;
4546

4647
public class KillAllByName extends ExecuteOSTask {
@@ -80,14 +81,22 @@ public String getLinuxCommand(String parameter) {
8081
}
8182

8283
@Override
83-
public JsonObject execute() {
84-
String command;
84+
public JsonObject execute(String parameter) {
85+
String command = "";
8586
if (RuntimeConfig.getOS().isWindows()){
8687
command = getWindowsCommand();
8788
} else {
8889
command = getMacCommand();
8990
}
90-
return execute(command);
91+
92+
String finalCommand = command + parameter;
93+
94+
JsonObject response = ExecuteCommand.execRuntime(finalCommand, waitToFinishTask);
95+
96+
response.addProperty("command", finalCommand);
97+
response.addProperty("wait_to_finish", waitToFinishTask);
98+
99+
return response;
91100
}
92101

93102
@Override

SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllChrome.java

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@
3737

3838
package com.groupon.seleniumgridextras.tasks;
3939

40-
import com.google.gson.JsonArray;
4140
import com.google.gson.JsonObject;
42-
import com.groupon.seleniumgridextras.ExecuteCommand;
43-
import com.groupon.seleniumgridextras.OS;
44-
import com.groupon.seleniumgridextras.config.RuntimeConfig;
4541

4642
public class KillAllChrome extends KillAllByName {
4743

@@ -58,49 +54,18 @@ public KillAllChrome() {
5854
setEnabledInGui(true);
5955
}
6056

61-
6257
@Override
63-
public JsonObject execute(String param) {
64-
//TODO: Make this work like killAllSafari and KillAllFirefox works
65-
if (RuntimeConfig.getOS().isWindows()) {
66-
return killChromeOnWindows();
67-
} else if (RuntimeConfig.getOS().isMac()) {
68-
return killChromeOnMac();
69-
} else {
70-
return killChromeOnLinux();
71-
}
72-
}
73-
74-
75-
private JsonObject killChromeOnLinux() {
76-
return ExecuteCommand.execRuntime(getLinuxCommand("[Cc]hrome"));
58+
public String getWindowsCommand() {
59+
return super.getWindowsCommand("chrome.exe");
7760
}
7861

79-
private JsonObject killChromeOnMac() {
80-
return ExecuteCommand.execRuntime(getMacCommand("[Cc]hrome"));
62+
@Override
63+
public String getLinuxCommand() {
64+
return super.getLinuxCommand("[Cc]hrome");
8165
}
8266

83-
private JsonObject killChromeOnWindows() {
84-
85-
JsonObject killBrowserResult = ExecuteCommand.execRuntime(getWindowsKillCommand("chrome.exe"));
86-
87-
JsonObject
88-
killDriverResult =
89-
ExecuteCommand.execRuntime(
90-
getWindowsKillCommand(RuntimeConfig.getConfig().getChromeDriver().getExecutableName()));
91-
92-
JsonArray response = new JsonArray();
93-
response.add(killBrowserResult);
94-
response.add(killDriverResult);
95-
96-
if (killBrowserResult.get("exit_code").equals("0") && killDriverResult.get("exit_code")
97-
.equals("0")) {
98-
getJsonResponse().addKeyValues("out", response);
99-
} else {
100-
getJsonResponse().addKeyValues("error", response);
101-
}
102-
103-
return getJsonResponse().getJson();
104-
67+
@Override
68+
public String getMacCommand() {
69+
return super.getMacCommand("[Cc]hrome");
10570
}
10671
}

SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllFirefox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public String getWindowsCommand() {
6363
public String getLinuxCommand() {
6464
return super.getLinuxCommand("[Ff]irefox");
6565
}
66-
66+
6767
@Override
6868
public String getMacCommand() {
6969
return super.getMacCommand("[Ff]irefox");

SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllIE.java

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@
3737

3838
package com.groupon.seleniumgridextras.tasks;
3939

40-
import com.google.gson.JsonArray;
41-
import com.google.gson.JsonObject;
4240

43-
import com.groupon.seleniumgridextras.ExecuteCommand;
44-
import com.groupon.seleniumgridextras.OS;
45-
import com.groupon.seleniumgridextras.config.RuntimeConfig;
41+
import com.google.gson.JsonObject;
4642

4743
public class KillAllIE extends KillAllByName {
4844

@@ -59,53 +55,19 @@ public KillAllIE() {
5955
setEnabledInGui(true);
6056
}
6157

62-
@Override
63-
public String getEndpoint() {
64-
return "/kill_ie";
65-
}
6658

6759
@Override
68-
public String getDescription() {
69-
return "Executes os level kill command on all instance of Internet Explorer";
60+
public String getWindowsCommand() {
61+
return super.getWindowsCommand("iexplore.exe");
7062
}
7163

7264
@Override
73-
public JsonObject execute(String param) {
74-
//TODO: Make this work like killAllSafari and KillAllFirefox works
75-
if (RuntimeConfig.getOS().isWindows()) {
76-
return killIEAndIEDriver();
77-
} else {
78-
getJsonResponse().addKeyValues("error", "Kill IE command is only implemented in Windows");
79-
return getJsonResponse().getJson();
80-
}
65+
public String getLinuxCommand() {
66+
return super.getLinuxCommand("iexplore.exe");
8167
}
8268

83-
84-
private JsonObject killIEAndIEDriver() {
85-
86-
JsonObject
87-
killBrowserResult =
88-
ExecuteCommand.execRuntime(getWindowsKillCommand("iexplore.exe"));
89-
90-
JsonObject
91-
killDriverResult =
92-
ExecuteCommand.execRuntime(
93-
getWindowsKillCommand(RuntimeConfig.getConfig().getIEdriver().getExecutableName()));
94-
95-
JsonArray response = new JsonArray();
96-
response.add(killBrowserResult);
97-
response.add(killDriverResult);
98-
99-
if (killBrowserResult.get("exit_code").equals("0") && killDriverResult.get("exit_code")
100-
.equals("0")) {
101-
getJsonResponse().addKeyValues("out", response);
102-
} else {
103-
getJsonResponse().addKeyValues("error", response);
104-
}
105-
106-
return getJsonResponse().getJson();
107-
69+
@Override
70+
public String getMacCommand() {
71+
return super.getMacCommand("iexplore.exe");
10872
}
109-
110-
11173
}

SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/KillAllIETest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737

3838
package com.groupon.seleniumgridextras;
3939

40-
import com.google.gson.JsonParser;
4140

42-
import com.groupon.seleniumgridextras.config.RuntimeConfig;
4341
import com.groupon.seleniumgridextras.tasks.ExecuteOSTask;
4442
import com.groupon.seleniumgridextras.tasks.KillAllIE;
4543
import org.junit.Before;
@@ -70,14 +68,4 @@ public void testGetEndpoint() throws Exception {
7068
assertEquals("/kill_ie", task.getEndpoint());
7169
}
7270

73-
@Test
74-
public void testOnlyWindowsSupported() throws Exception {
75-
76-
if (!RuntimeConfig.getOS().isWindows()) {
77-
assertEquals(
78-
new JsonParser().parse("{\"exit_code\":1,\"error\":[\"Kill IE command is only implemented in Windows\"],\"out\":[]}"),
79-
task.execute());
80-
}
81-
}
82-
8371
}

0 commit comments

Comments
 (0)