简体   繁体   中英

Kill instances of Internet Explorer remotely from linux machine using Java

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!

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");

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM