robotframework使用SSHLib

robotframework使用SSHLib:
1、首先需要安装SSHlib,由于SSHlib也需要一些其他的库,建议使用pip安装。
参考网址:https://pypi.python.org/pypi/robotframework-sshlibrary

2、安装pip:
到https://pypi.python.org/pypi/pip上下载,我下载的是:pip-8.1.2.tar.gz (md5, pgp)
解压缩,安装:python setup.py install

3、安装pip后:pip install robotframework-sshlibrary

4、安装完毕后,写个简单的测试例子:
ssh_testsuit.txt:
*** Settings ***
Library           SSHLibrary

*** Variables ***
${host}           172.16.164.140    # host ip or hostname
${port}           22    #ssh port,default 22
${username}       root    #login username
${password}       123456    # login password
${command}        uptime    # the command excuted

*** Test Cases ***
ssh testcase
    Open Connection    ${host}    ${port}
    login    ${username}    ${password}
    Start Command    ${command}
    ${stdout}    ${stderr}    Read Command Output     return_stderr=True
    Should Be Empty    ${stderr}

运行:
robot -d ./result ssh_testsuit.txt 

附注:python版本为2.7
发布了54 篇原创文章 · 获赞 1 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/xingyeping/article/details/52230250