Stop Chrome and Edge on script start

"package com.customkeywords

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.util.KeywordUtil

class KillBrowsers {

@Keyword
def killEdgeAndChromeProcesses() {
    String os = System.getProperty("os.name").toLowerCase()

    List<String> commands = []
    if (os.contains("win")) {
        commands.add("taskkill /F /IM chrome.exe")
        commands.add("taskkill /F /IM msedge.exe")
    } else if (os.contains("mac") || os.contains("linux")) {
        commands.add("pkill -f 'Google Chrome'")
        commands.add("pkill -f 'Microsoft Edge'")
    } else {
        KeywordUtil.markFailed("Unsupported OS: " + os)
        return
    }

    commands.each { command ->
        try {
            Process process = command.execute()
            process.waitFor()
            KeywordUtil.logInfo("Command executed: " + command)
        } catch (Exception e) {
            KeywordUtil.markFailed("Failed to terminate browsers with command [" + command + "]: " + e.getMessage())
        }
    }
}

}
"

Hi Ian,

Welcome to Katalon Community! :wave:

Could you provide more information on what you are trying to do in your topic, so that our team and other members can support your better?

Please refer to the topic below :point_down:

Thanks :+1: