基本使用步骤:
- 创建项目(New Project)
- 创建模块(New Directory)
- 创建测试套件(New Suite)
- 创建测试用例(New Test Case)
- 创建资源文件(New Resource)
- 创建业务关键字(New User Keyword)
- 常用关键字用例编写
- robot报告显示

- 创建项目(New Project)
File --> New Project,Type选择Directory,Format选择Robot
 
- 创建模块(New Directory)
 鼠标右键点击项目 --> 选择New Directory
  
- 创建测试套件(New Suite)
 鼠标右键点击模块 --> 选择New Suite
  
- 创建测试用例(New Test Case)
 鼠标右键点击Suite --> 选择New Test Case
  
- 创建资源文件(New Resource)
 资源文件是【自定义关键字】的载体
 注意:只能在文件夹下面进行创建,并且是txt格式的
  
- 创建业务关键字(New User Keyword)
 在资源文件下新建业务关键字
  
- 常用关键字用例编写
 以下这些都是robot常用关键字,但其实我们自己的项目中进行UI/App自动化时,我们一般会使用自定义关键字
  
testcase003
    Comment    1、打印
    Log    你好
    Comment    2、设置变量
    ${a}    Set Variable    100Log    ${a}Comment    3、获得系统时间
    ${time}    Get TimeComment    4、睡眠时间,强制等待
    Comment    sleep    3Comment    5、字符串的拼接
    ${str}    Catenate    oracle    mysql    sqlserver
    Log    ${str}Comment    6、创建列表
    ${list1}    Create List    11    22    33Log    ${list1}
    @{list2}    Create List    44    55    66LogMany    @{list2}Comment    7、创建字典
    ${dic}    Create Dictionary    name=mikasa    age=17Log    ${dic}
    ${keys}    Get Dictionary Keys    ${dic}Log    ${keys}
    ${values}    Get Dictionary Values    ${dic}Log    ${values}
    ${key_value}    Get From Dictionary    ${dic}    name
    Log    ${key_value}Comment    8、执行python里面的方法
    ${random_num}    Evaluate    random.randint(1,101)    modules=random
    Log    ${random_num}
    ${time}    Evaluate    time.time()    modules=time
    Log    ${time}Comment    9、用自定义的方法
    Import Library    D:/Users/**/PycharmProjects/PythonProject0329/base.py
    ${a}    Set Variable    mi
    ${b}    Set Variable    hongguang
    ${return_result}    join_two_strings    ${a}    ${b}Log    ${return_result}Comment    10、流程控制IF
    ${score}    Set Variable    62Run Keyword If    ${score}<60    Log    不及格
    ...    ELSE IF    60<=${score}<=80    Log    良好
    ...    ELSE    Log    优秀
    Comment    11、流程控制ForFOR    ${a}    IN    MYSQL    ORACLE    JAVALog    ${a}ENDComment    12、For遍历数组
    @{list3}    Create List    MYSQL    ORACLE    JAVAFOR    ${a}    IN    @{list3}Log    ${a}ENDComment    13、For遍历数字范围
    FOR    ${a}    IN RANGE    1    10Run Keyword If    ${a}==5    Exit For LoopLog    ${a}END
base.py
 实现字符串拼接
def join_two_strings(arg1, arg2):return arg1 + "-" + arg2
- robot报告显示:
  



















