使用robotframework登录远程机器

学习robotframework自动化

安装python2.7.14

安装wxpython

安装wxpython主要是为了后续使用robotframework-ride。如果不使用图形化界面,可以不安装。
软件版本:wxPython2.8-win32-unicode-2.8.12.1-py27.exe
下载地址https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/

安装robotframework框架

pip install robotframework
pip install robotframework-ride

启动robotframework-ride

进入python交互界面,输入

from robotide import main
main()

测试robotframework

*** Test Cases ***
First test case
    Begin web test

Second test case
    End web test

*** Keywords ***
Begin web test
    Log    This is first test case

End web test
    Log    end

输出

*** Test Cases ***
First test case
    Begin web test

Second test case
    End web test

*** Keywords ***
Begin web test
    Log    This is first test case

End web test
    Log    end
可以在桌面新建快捷方式

首先在桌面上点击鼠标右键,选择新建–》快捷方式,然后在输入框输入D:\Python27\pythonw.exe -c”from robotide import main;main()”

远程登录主机

首先需要安装paramiko和ssh库

pip install paramiko
pip install robotframework-SSHLibrary

编写脚本

*** Settings ***
Library           SSHLibrary

*** Test Cases ***
First test case
    Begin web test

Second test case
    End web test
    Open Connection    192.168.153.11    port=22
    Login    root    888999
    Write    touch /etc/test

*** Keywords ***
Begin web test
    Log    This is first test case

End web test
    Log    end

* 也可以直接将脚本文件存储为test.txt格式,使用pybot test.txt执行 *

参考 https://blog.csdn.net/liumiaocn/article/details/72953213

你可能感兴趣的:(使用robotframework登录远程机器)