zoukankan      html  css  js  c++  java
  • RF--基础

    常用关键字:

    ${var}  set variable  hello world  #${var}为变量的常用书写格式,set variable设置变量,均为字符串

    ${var2}  set variable  hello world  #${var}为变量的常用书写格式,set variable设置变量,均为字符串

    log to console  ${var}  #会输出到控制台

    log  ${var}  #不会输出到控制台,会输出到日志里

    sleep  1  #默认单位为秒s,可以设置其他单位1d,2h,3m,4s,5ms,例sleep 5ms

    should be equal  ${var}  hello world  #判断

    should contian  ${var}  hello  #断言${var}中是否包含hello

    should be true  'hello word'==$var  #这里把  'hello word'==$var  看成一个字符串表达式,当${var}为字符串时,在should be true调用时会省去引号

    should be true注释:

    *** Test Cases ***
    case1:
        ${var}  set variable  hells
        should be true  hello == ${var}
    结果:FAIL
    Evaluating expression 'hello == hells' failed: NameError: name 'hello' is not defined
    此次报错信息为hello未定义,在python中字符串hello应写为'hello'
    
    case2把hello改为'hello',此处变量依旧用hells是为了体现是变量错误
    *** Test Cases ***
    case2:
        ${var}  set variable  hells
        should be true  'hello' == ${var}
    结果:FAIL
    Evaluating expression ''hello' == hells' failed: NameError: name 'hells' is not defined
    报错信息为'hells'未定义,在rf中的should be true比较中,调用字符串变量时,直接取引号''内部的数据
    
    *** Test Cases ***
    case3:
        ${var}  set variable  hello
        should be true  'hello' == '${var}'
    结果:PASS
    直接在调用的字符串变量外部加引号来弥补本身调用的问题
    
    *** Test Cases ***
    case4:
        ${var}  set variable  hello
        should be true  'hello' == $var
    结果:PASS
    另一种书写方式,在should be true中, 加引号'${var}'和去大括号$var代表的意思相同
    
    *** Test Cases ***
    case5:
        ${var}  set variable  [1,2]
        should be true  '[1,2]' == $var
    结果:PASS
    在遇到变量不是字符串格式时,依旧如同case4的格式书写
  • 相关阅读:
    Project Chameleon Work In Progress 14
    All about Project Chameleon
    网页中图片连续滚动代码 (转)
    一点感言
    一些常用javascript代码(转)
    asp.net(c#)的一个非常非常奇怪的问题
    用javascript拦截a标签的超链接执行
    asp.net中用TreeView控件实现无限分级的好办法
    windows7 安装ez usb基本驱动
    管道编程
  • 原文地址:https://www.cnblogs.com/guang2508/p/13258413.html
Copyright © 2011-2022 走看看