【发布时间】:2021-07-05 15:10:49
【问题描述】:
我是 Cypress 和 Javascript 的新手
我正在尝试通过赛普拉斯发送系统命令。我已经经历了几个例子,但即使是最简单的也不起作用。 它总是失败并显示以下消息
Information about the failure:
Code: 127
Stderr:
/c/Program: Files\Git\usr\bin\bash.exe: No such file or directory`
我正在尝试 cy.exec('pwd') 或 'ls' 来查看它是从哪里启动的,但它不起作用。 是否有我遗漏的特定内容?一些特殊的配置?
编辑: 确实,我不清楚我试图在其中使用命令的上下文。但是,我没有明确设置任何路径。
我在 linux 服务器上发送请求,但我也想发送系统命令。
我的柏树项目在/c/Cypress/test_integration/cypress
我使用位于/c/Cypress/test_integration/cypress/features/System 的.feature 文件,我的场景调用位于/c/Cypress/test_integration/cypress/step_definitions/generic 的文件system.js 中的一个函数。
System_operations.features:
Scenario: [0004] - Restore HBox configuration
Given I am logging with "Administrator" account from API
And I store the actual configuration
...
然后我的.js文件,我要发送系统命令
system.js:
Given('I store the actual configuration', () => {
let nb_elem = 0
cy.exec('ls -l')
...
})
我没有在VS Code中为使用bash命令做特定的路径配置(我只是在bash而不是powershell中配置了终端)
【问题讨论】:
-
由于您遇到问题但决定完全不重要的秘密命令中的路径,请尝试使用引号来保护错误消息中清晰可见的空格字符!还请基于您不是本站新成员的事实,重新访问How to Ask,特别注意提交您的代码minimal reproducible example!