RF-SSHLibrary测试库「用于SSH和SFTP」

安装方法:

pip install --upgrade robotframework-sshlibrary

脚本分享:

*** Settings ***

Library SSHLibrary

*** Variables ***

${username} root

${password} root

${i_item} empty

*** Keywords ***

get_pid_kill

${pid_list} Evaluate '''${i_item}'''.split()

${pid_item} Evaluate ${pid_list}[1]

# ${pid_len} Evaluate len(${pid_list})

# :FOR ${j} IN RANGE ${pid_len}

# \ log ${j}

# \ ${pid_item} Evaluate ${pid_list}[${j}]

# \ log

Execute Command kill -9 ${pid_item}

*** Test Cases ***

219服务器

[Tags] 219

Open Connection ip

${output}= Login ${username} ${password}

Should Contain ${output} \#

${rc} Execute Command ps -ef |grep tomcat

${rc_list} Evaluate '''${rc}'''.splitlines() modules=string

${rc_list_len} Evaluate len(${rc_list})

:FOR ${i} IN RANGE ${rc_list_len}

\ log ${i}

\ ${i_item} Evaluate ${rc_list}[${i}]

\ ${i_res} Run Keyword And Return Status Should Contain ${i_item} java

\ Set Suite Variable ${i_item}

\ Run Keyword If '${i_res}'=='True' get_pid_kill

Close Connection

你可能感兴趣的:(RF-SSHLibrary测试库「用于SSH和SFTP」)