RobotFrameWork基础一
1.变量:
作用域:
Set Global Variables:设定全局级变量
Set Suite Variables: 设定Test Suite 级变量
Set Test Variable:设定Test Case级变量
定义:
脚本中使用 Set Variable 定义变量
普通变量:${}
list变量:@{},也可以使用 Creat List 关键字创建List变量
@{list1} Set Variable 1 2 3 4
Log Many @{list1}
@{list2} Create List a b c
Log Many @{list2}
字典:&{}
&{dic} Create Dictionary name=Jack age=18 Job=Student
Log ${dic} #输出整个字典
Log Many &{dic} # 输出字典里的值
${name} Get From Dictionary ${dic} name
Log ${name}
Log ${dic}[age]
Log ${dic.Job}
2.Settings
Documention:add suite description
Suite Up:before run the suite, keyword below the suite first
Suite Teardown: when the suite finished, run the keyword below the suite
Test Setup:before the case start,run the keyword
Test Teardown:when the case finished,run the keyword
Test Template:测试用例模板,指定某个关键字为这个测试套件下所有测试用例模板,之后所有用例传参只需要 填写该关键字即可
Test Timeout:设置suite下每条case超时时间,超过该时间则失败停止运行
Force Tags:force to suite and add tag label to the cases
Default Tags: add default tags for the cases [suite]
Library:import library
Resource:import resource
3.if,for结构
testif
${num1} Set Variable 5
${num2} Set Variable 1
Run Keyword If ${num1}>100 Log num1>100
... ELES IF ${num2}>0 Log num2>0
... ELSE Log num1不大于100 and mun2 也不大于0
testfor
@{list} Set Variable a b c d
FOR ${i} IN @{list}
Log To Console ${i}
END
TestCase03
${a} Create List 1 2 3 4
${b} Create List 11 22 33 44
@{listtest} Create List ${a} ${b}
FOR ${li} IN @{listtest}
Log To Console ${li}
嵌套循环 @{li}
END
*** Keywords ***
嵌套循环
[Arguments] @{list}
FOR ${i} IN @{list}
Log To Console ${i}
END
test for in range
FOR ${i} IN RANGE 1 10
Log To Console ${i}
END
test for in enumerate
@{li} Create List a b c d
FOR ${index} ${element} IN ENUMERATE @{li}
Log ${index}: ${element}
END
TestCase04
FOR ${index} ${name} ${n} ${m} IN ENUMERATE cat 猫 12 dog 狗 9
Log ${index}-${name}-${n}-${m}
END
test for in zip
@{list} Create List 1 2 3 4
${c} Create List a b c d
FOR ${number} ${char} IN ZIP ${list} ${c}
Log ${list} - ${c}
END
3.列表变量和元素获取
testcase06
@{list} Create List 1 2 3 4
${len} Get Length ${list}
Log To Console ${len}
FOR ${value} IN @{list}
Log ${value}
END
Log To Console ${list[0]}
Log To Console ${list}[0]
# Log To Console @{list}[0] #错误写法 取值要用$
${li} Set Variable 1 3 5 7
Log To Console ${li}[0]
引入外部变量:
引入单值变量:--variable(-v) name:value , name对应的是${}变量名,value对应的是值。--escape可以转义特殊字符串
引入外部变量文件:--variablefile(-V)
example:
--variable Name:Jack
--variable --escape quot:Q --escape space:_
--variablefile path/to/variables.py
最新文章
- Python模拟登陆新浪微博
- yii小细节
- js中的replace全局替换
- 以sysdba身份登录oracle报ORA-1031权限不足错误之完美分析
- C++ 复制构造函数
- Java小应用程序Applet,画布上新建按钮和文本
- paip.中文 分词 -- 同义词大全整理
- 配置JDKAndroid 2D游戏引擎AndEngine
- 【BZOJ】3224: Tyvj 1728 普通平衡树(某不科学的oj)
- SYBASE时间计算
- windows下 composer常见问题及处理
- Cnblogs美化总结
- jQuery使用():Callbacks回调函数列表之异步编程(含源码分析)
- Webpack4教程:第一部分,入口、输入和ES6模块
- C#总结小程序
- 如何高效地写CSS--等以后有空多加总结一下
- ES6躬行记(4)——模板字面量
- May 27. 2018 Week 22nd Sunday
- day33 网络编程之线程,并发以及selectors模块io多路复用
- C#读取wav文件