Automation One By One - Robot Framework - 变量及赋值
来源:互联网 发布:淘宝2016促销活动时间 编辑:程序博客网 时间:2024/06/07 03:55
前面已经提到变量有三类,一类是scalar variable ${variable},一类是list variable,还有一类是内置(Built-in)的变量.
1. 给scalar variable类型的变量赋值:${scalar variable}
(1)${scalar variable}= simple strings
(2)${scalar variable}= objects
无论scalar类型的变量被赋予什么值,这个值先被转换成Unicode,然后再按字符串显示出来。转换的过程相当于调用这个对象的__unicode__,__str__
2. 给list variable赋值: @{variable}
(1)列表变量中的值,可以是一个,也可以是多数(无数),还可以是空
(2)列表变量的值通常是字符类型的,其它类型的也可以
(3)可以通过@{NAME}[i]形式来访问列表中的某一个值
(4)可将list variables当作scalar类型的变量使用,使用方法是将list变量的符号从@替换成$就可以了;这种表达式让我们使用built-in类库及Collection类库中list相关的keywords成为可能。
(5)list变量可以应用在setting table中,但仅限于一部分的settings命令可用。
Using list variables with settings Settings Value Value Comment LibraryExampleLibrary@{LIB ARGS}# This worksLibrary${LIBRARY}@{LIB ARGS}# This worksLibrary@{NAME AND ARGS} # This does not workSuite SetupSome Keyword@{KW ARGS}# This worksSuite Setup${KEYWORD}@{KW ARGS}# This worksSuite Setup@{KEYWORD} # This does not workDefault Tags@{TAGS} # This works
3. 给Envrionment Variables赋值:%{ENV_VAR_NAME}
(1)只能赋值string类型的值
(2)可于OperatingSystem library类库中的keyword一块应用
4. 可以将keyword中返回的值作为变量存储
${keyword_return_value}= Get Matching Xpath Count [locator]
${keyword_return_value}= Get Element Attribute [locator]
...
5. 内置Build-in变量
Available operating-system-related built-in variables Variable Explanation ${CURDIR}An absolute path to the directory where the test datafile is located. This variable is case-sensitive.${TEMPDIR}An absolute path to the system temporary directory. In UNIX-likesystems this is typically/tmp, and inWindowsc:\Documents and Settings\<user>\Local Settings\Temp.${EXECDIR}An absolute path to the directory where test execution wasstarted from. New in Robot Framework 2.1.${/}The system directory path separator./in UNIX-likesystems,\in Windows.${:}The system path element separator.:in UNIX-likesystems and;in Windows.
Variable Explanation Available ${TEST NAME}The name of the current test case.Test case@{TEST TAGS}Contains the tags of the current test case inalphabetical order.Test case${TEST STATUS}The status of the current test case, either PASS orFAIL.Test teardown${TEST MESSAGE}The possible error message of the current test case.Test teardown${PREV TEST NAME}The name of the previous test case, or an empty stringif no tests have been executed yet.Everywhere${PREV TEST STATUS}The status of the previous test case: either PASS,FAIL or an empty string when no tests have beenexecuted.Everywhere${PREV TEST MESSAGE}The possible error message of the previous test case.Everywhere${SUITE NAME}The full name of the current test suite.Everywhere${SUITE SOURCE}An absolute path to the suite file or directory. Newin Robot Framework 2.5.Everywhere${SUITE STATUS}The status of the current test case, either PASS orFAIL.Suite teardown${SUITE MESSAGE}The full message of the current test suite, includingstatistics.Suite teardown${OUTPUT FILE}An absolute path to the currentoutput file. Hasdifferent values during execution whenoutputs are split.Everywhere${LOG FILE}An absolute path to the currentlog fileor stringNONE when no log file is created. Has different valuesduring execution whenoutputs are split.Everywhere${REPORT FILE}An absolute path to thereport fileor string NONEwhen no report is created.Everywhere${SUMMARY FILE}An absolute path to thesummary fileor string NONEwhen no summary is created.Everywhere${DEBUG FILE}An absolute path to thedebug fileor string NONEwhen no debug file is created.Everywhere${OUTPUT DIR}An absolute path to theoutput directory.
1. 给scalar variable类型的变量赋值:${scalar variable}
(1)${scalar variable}= simple strings
(2)${scalar variable}= objects
无论scalar类型的变量被赋予什么值,这个值先被转换成Unicode,然后再按字符串显示出来。转换的过程相当于调用这个对象的__unicode__,__str__
2. 给list variable赋值: @{variable}
(1)列表变量中的值,可以是一个,也可以是多数(无数),还可以是空
(2)列表变量的值通常是字符类型的,其它类型的也可以
(3)可以通过@{NAME}[i]形式来访问列表中的某一个值
(4)可将list variables当作scalar类型的变量使用,使用方法是将list变量的符号从@替换成$就可以了;这种表达式让我们使用built-in类库及Collection类库中list相关的keywords成为可能。
(5)list变量可以应用在setting table中,但仅限于一部分的settings命令可用。
- 对于Library及Resource的settings来说list变量不能作为其name使用,只能作为argument使用
- 对于Setup/Teardown的settings来说list变量不能当作keyword的name使用,只能作为argument使用
- 对于tag的settings来说可以随意使用
- 对于不支持list变量的settings来说,我们可以使用scalar变量的形式来表达(如library及setup中的name不能使用list变量,我们可以用scalar变量代替list变量)
3. 给Envrionment Variables赋值:%{ENV_VAR_NAME}
(1)只能赋值string类型的值
(2)可于OperatingSystem library类库中的keyword一块应用
4. 可以将keyword中返回的值作为变量存储
${keyword_return_value}= Get Matching Xpath Count [locator]
${keyword_return_value}= Get Element Attribute [locator]
...
5. 内置Build-in变量
- Automation One By One - Robot Framework - 变量及赋值
- Automation One By One - Robot Framework - 数据类型
- Automation One By One - Robot Framework - Test Suite
- Automation One By One - Robot Framework - Keyword/Variable Files
- Automation One By One - Robot Framework - 优化Test Case
- Automation One By One - Robot Framework - User Keywords
- one by one note
- COPY CHAR ONE BY ONE
- Angular2 (One framework 概要)
- Robot Framework For Mobile Test Automation
- Robot Framework 内置变量
- off-by-one error
- off by one
- Leetcode One by One----Two Sum
- One
- one
- one:
- One
- spring整合
- Automation One By One - Robot Framework - 数据类型
- ALV中fieldcat,layout常设字段
- 三星:Galaxy Nexus从设计之初就避免和苹果打专利战
- 名企笔试真题精选(三)
- Automation One By One - Robot Framework - 变量及赋值
- Automation One By One - Robot Framework - User Keywords
- shell脚本基础
- NTDDI_VERSION,_WIN32_WINNT,WINVER,_WIN32_IE定义宏的含义
- Tomcat7.0 在Windows7下的安装
- CPU的大端模式和小端模式
- 关于释放指针引发的一个错误
- Shell脚本编程详解
- delphi中处理OleVariant和TStream