私もこの問題を抱えていました。testSetup()メソッドで実行中のchromedriver.exeのインスタンスをすべて強制終了することで修正しました。スクリプトを実行するために、VBScriptといくつかのGroovyコードを使用しました。申し訳ありませんが、この回答は長いです。
私は私のセットアップでこれを持っていました):
if (wshsc.isRunningByCommandLineContents("chromedriver.exe"))
wshsc.killProcessByCommandLineContents("chromedriver.exe")
isRunningByCommandLineContents:
If WScript.Arguments.Count = 1 Then
strCmdLine = WScript.Arguments.Item(0)
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objShell = CreateObject("WScript.Shell")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process")
If colProcessList.Count > 0 Then
For Each objItem in colProcessList
If (InStr(objItem.CommandLine, strCmdLine)) Then
If (InStr(objItem.CommandLine, "cscript")) Then
Else
WScript.StdOut.Write "A process is running with " + strCmdLine + " in its command line = " + objItem.Name
End If
End If
Next
End If
End If
killProcessByCommandLineContents:
If WScript.Arguments.Count = 1 Then
strProcess = WScript.Arguments.Item(0)
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objShell = CreateObject("WScript.Shell")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process")
If colProcessList.Count > 0 Then
For Each objItem in colProcessList
If InStr(objItem.CommandLine, strProcess) Then
If (InStr(objItem.CommandLine, "cscript")) Then
Else
WScript.StdOut.Write objItem.Name + " "
objItem.Terminate()
End If
End If
Next
Else
WScript.StdOut.Write "No instances found running"
End If
Else
WScript.StdOut.Write "Bad Arguments"
End If
そして「スクリプトの実行部分」:
public void killProcessByCommandLineContents(String contents) {
List<String> arg = new ArrayList<String>()
arg.add(contents)
String [] args = arg.toArray()
runScript("killByCmdLineContents.vbs", args, true)
}
public boolean isRunningByCommandLineContents(String contents) {
List<String> arg = new ArrayList<String>()
arg.add(contents)
String [] args = arg.toArray()
String returnData = runScript("IsRunningByCmdLineContents.vbs", args, true)
if (returnData.contains(contents)) {
return true
} else {
return false
}
}
public String runScript(String name, String [] args, boolean returnOutput) {
String s = null;
List<String> cmdLine = new ArrayList<String>()
cmdLine.add("C://Windows//System32//cscript.exe")
cmdLine.add(dir + "dir//src//com//misc//wshScripts//" + name)
int index = 0
args.each() {
cmdLine.add(args[index])
index++
}
try {
String [] cmdLineArray = cmdLine.toArray()
Process p = Runtime.getRuntime().exec(cmdLineArray, null);
if (returnOutput) {
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String dataToReturn
Log.logger.info("Standard output: ");
while ((s = stdInput.readLine()) != null) {
Log.logger.info(s)
dataToReturn = s // should get last line
}
Log.logger.info("Standard error: ");
while ((s = stdError.readLine()) != null) {Log.logger.info(s);}
return dataToReturn
} else {
return ""
}
}
catch (IOException e) {
Log.logger.info(e.message, e);
}
}