zoukankan      html  css  js  c++  java
  • katalon系列十四:执行Windows命令&获取项目路径

    Katalon Studio中也可以运行Windows命令执行一些系统操作。

    根据官方文档,在test case中输入命令:
    cmd = 'del E:\shot\*.xlsx E:\shot\*.zip'
    Runtime.getRuntime().exec(cmd)

    运行报错

    网上搜到解决方案,修改cmd如下
    cmd = 'cmd.exe /c del E:\shot\*.xlsx E:\shot\*.zip'

    运行成功

    除了直接运行cmd命令,也可以执行.bat文件,代码示例如下

    import com.kms.katalon.core.configuration.RunConfiguration
    /**
    * Execute a batch file situated in the KS project directory.
    * @param batchFile (String) e.g. "myfile.bat"
    */
    static void runBatchFile(String batchFile) {
    String bf = RunConfiguration.getProjectDir() + '/' + batchFile
    comment("Running batch file: " + bf)
    Runtime.runtime.exec(bf)
    }

    RunConfiguration.getProjectDir()即为获取项目路径,记得要导入相应的包

    参考https://docs.katalon.com/katalon-studio/docs/execute-windows-commands.html

    ---------------------------------------------------------------------------------

    关注微信公众号即可在手机上查阅,并可接收更多测试分享~

  • 相关阅读:
    洛谷 P2327 [SCOI2005]扫雷 题解
    P1388 算式 题解
    P1281 书的复制 题解
    P2896 [USACO08FEB]一起吃饭Eating Together 题解
    P1140 相似基因 题解
    变量的解构赋值
    let 和 const 命令
    第一阶段站立会议8
    第一阶段站立会议7
    第一阶段站立会议6
  • 原文地址:https://www.cnblogs.com/songzhenhua/p/10187201.html
Copyright © 2011-2022 走看看