我目前正在Robot Framework中使用Eclipse和RED插件开发测试用例,以在Linux VM上自动化测试用例。其中一个关键字的代码如下
**Check Auth Certificate**
[Documentation] To Check Whether the Authentication certificate is present or not
Log *** Needs to be implemented ***
Send Command pwd
Send Command cd /root/.ssh/
Send Command pwd
${fileExist} File Should Exist 'mqtt-server.crt'
发送命令是一个自定义关键字,用于使用Write&读取Keywords并记录结果。问题是,在这个位置有一个文件(mqtt-server.crt(-/root/.ssh/。从控制台输出中,我可以验证控件是否已到达所需的文件夹中。但是,当执行SSHLibrary-文件应该存在中的关键字时,它将失败。我想验证提到的文件是否存在于文件夹中,如果存在,则需要删除。控制台中的输出为
20210623 00:23:47.024 : INFO : *** Needs to be implemented ***
20210623 00:23:47.118 : INFO : pwd
20210623 00:23:48.120 : INFO : /root
[root@<host> ~]#
20210623 00:23:48.121 : INFO : Response After :: pwd - -> /root
[root@<host> ~]#
20210623 00:23:48.226 : INFO : cd /root/.ssh/
20210623 00:23:49.227 : INFO : [root@<host> .ssh]#
20210623 00:23:49.227 : INFO : ${resultCommand} = [root@<host> .ssh]#
20210623 00:23:49.228 : INFO : Response After :: cd /root/.ssh/ - -> [root@<host> .ssh]#
20210623 00:23:49.320 : INFO : pwd
20210623 00:23:50.321 : INFO : /root/.ssh
20210623 00:23:50.321 : INFO : ${resultCommand} = /root/.ssh
20210623 00:23:50.408 : INFO : ls
20210623 00:23:50.408 : INFO : ${responseCommand} = ls
20210623 00:23:52.411 : INFO : known_hosts mqtt-server.crt
20210623 00:23:52.411 : INFO : ${resultCommand} = known_hosts mqtt-server.crt
[root@<host> .ssh]#
20210623 00:23:52.413 : INFO : Response After :: ls - -> known_hosts mqtt-server.crt
[root@<host> .ssh]#
20210623 00:23:52.413 : INFO : ${listOfFiles} = None
**20210623 00:23:52.415 : DEBUG : [chan 1] Max packet in: 32768 bytes
20210623 00:23:52.529 : INFO : [chan 1] Opened sftp connection (server version 3)
20210623 00:23:52.529 : DEBUG : [chan 1] normalize(b'.')
20210623 00:23:52.570 : DEBUG : [chan 1] stat(b'mqtt-server.crt')
20210623 00:23:52.603 : FAIL : File 'mqtt-server.crt' does not exist.
20210623 00:23:52.604 : DEBUG : Traceback (most recent call last):
File "D:Program Files (x86)PythonPython39Libsite-packagesSSHLibrarylibrary.py", line 1809, in file_should_exist
raise AssertionError("File '%s' does not exist." % path)**
Ending test: Demo-Telemetry.TestCases.ConnectToJumpServer.First Jump
你能告诉我吗,需要改变什么才能让它发挥作用,或者如何解决这个问题。
在"文件应该存在";关键字。或者使用";移动目录";关键字。我不认为,如果您更改自定义关键字中的目录,这个目录会为操作系统库更改。
${fileExist} File Should Exist /root/.ssh/mqtt-server.crt