【问题标题】:Robot Framework - run powershell which replaces value in ini file机器人框架 - 运行 powershell 替换 ini 文件中的值
【发布时间】:2020-07-28 23:17:47
【问题描述】:

我的 Robot Framework 测试用例有问题:

*** Settings ***

Library  Process

*** Test Cases ***

Change my ini file
  run process  powershell.exe  ${CURDIR}/test.ps1

*** Variables ***
${CURDIR}  C:/RobotFramework

${CURDIR} 是 C:/RobotFramework,我的 test.ps1 包含:

(Get-Content -Path "C:\RobotFramework\my.ini") | Foreach-Object {$_ -replace '^Test.*', ('Test=10')} | Set-Content 'C:\RobotFramework\my.ini'

当我在 ps 命令行中以这种方式启动脚本时,脚本本身可以正常工作: powershell -ExecutionPolicy 绕过 -File 'C:\RobotFramework\test.ps1'

测试用例以 OK 状态通过,但它不会将 my.ini 文件中的测试更改为 10。 请告诉我,我在这里做错了什么?

【问题讨论】:

    标签: powershell process robotframework


    【解决方案1】:

    我为自己的问题找到了解决方案:D

    我试过了:

    更改我的ini文件

      ${test}  Run And Return Rc And Output  powershell.exe -ExecutionPolicy Bypass -File "C:\\RobotFramework\\test.ps1"
    
      log to console  ${test}
    

    它有效! :D

    【讨论】:

      猜你喜欢
      • 2013-05-14
      • 1970-01-01
      • 1970-01-01
      • 2016-05-03
      • 2013-04-11
      • 2014-11-28
      • 2021-02-10
      • 2016-05-19
      • 2018-03-13
      相关资源
      最近更新 更多