I have several Selenium tests being run remotely from Jenkins (on Linux) to a Windows machine using Selenium Grid. I need a way to reliably kill
all instances of IE before a test even begins. These tests all run end-to-end using TestNG, so this method needs to be executed at the beginning of each test, in the @BeforeMethod
. I know how to use Java to kill
the tasks, but since the code is actually deployed on a Linux machine those won't work (to my knowledge). Any help would be appreciated!
Asked
Active
Viewed 156 times
-1

kroe761
- 3,296
- 9
- 52
- 81
-
Thank you for that. Every time I post extra information, it usually gets immediately edited and removed. But if I try to be concise and to the point, I get scolded for that as well. It's certainly not like I've spent most of the day working on this... – kroe761 Sep 01 '17 at 18:50
-
You will want to be concise and to the point but at least show us what you've read as research, code you've tried, and explain what is not working with your current attempts, e.g. error messages, etc. – JeffC Sep 01 '17 at 18:55
3 Answers
1
You can use winrm4j to execute commands from java code on remote windows box. Something like:
WinRmTool.Builder cmdTool = createWinRmBuilder();
cmdTool.environment(environment);
WinRmToolResponse cmdResponse = cmdTool.build().executeCommand("taskkill /F /IM iexplore.exe /T");

timbre timbre
- 12,648
- 10
- 46
- 77
1
You can either use some remote management tools for that, or just create a micro service, which will be running on a target workstation and accept http requests with commands for remote file system / tasks management.
Check this article, which describes how to build a simple service and Jenkins plugin for such kind of tasks. There're links on sources as well.

Serhii Korol
- 843
- 7
- 15
0
create a bat file on Windows PC and write the following line
taskkill /F /IM iexplore.exe /T
it will kill all the instances of Internet Explorer. Now everytime you want to make sure all the internet explorer instances are closed. Run this bat file

Sahil Manchanda
- 9,812
- 4
- 39
- 89
-
I actually need this method to be in Java code, executed on a Linux machine to kill a remote windows task at the beginning of each test in a test suite. I didn't explain this adequately, apologies. – kroe761 Sep 01 '17 at 16:24
-
-
Can ProcessBuilder execute an application on a different machine from the one that is running the java code? I looked, and i didn't see a way to specify the other machine address anywhere. – kroe761 Sep 01 '17 at 18:47