html tool

显示标签为“robotframework”的博文。显示所有博文
显示标签为“robotframework”的博文。显示所有博文

2020年12月31日星期四

解决: [ WARN ] Accessing variable items using '@{result_values}[1]' syntax is deprecated. Use '${result_values}[1]' instead.

参考: https://github.com/robotframework/robotframework/issues/2601

【popexizhi: 之前是 robotframework               3.1.1

看这个应该是3.2 的新功能了:)

Changing the meaning of @{var}[x] and &{var}[x] is backwards compatible and requires graceful deprecation. My proposal is to do it like this:

  1. In RF 3.0.3 add the support for using ${var}[x] and also ${var}[nested][x] with variables containing lists and dictionaries. Don't change @{var}[x] and &{var}[x] syntax.

  2. In RF 3.1 deprecate using @{var}[x] and &{var}[x]. Issue a warning if the syntax is used but don't change the functionality yet.

  3. In RF 3.2 change @{var}[x] and &{var}[x] to mean using variable ${var}[x] as a list or dictionary, respectively.

@aaltat
Contributor

aaltat commented on 24 May 2017

I am pretty happy with the extended variable syntax. But I agree that it's quite painful to remember which way to write the square brackets in the variables. I think supporting ${var}[x][y][z] is a good idea.

2020年9月21日星期一

转:robot -e 不执行的tag设置

 https://blog.csdn.net/weixin_41407477/article/details/82626977

tag如何使用:

tag可以是自己定义,而且可以一个测试用例可以打多个tags

 -i --include tag *       Select test cases to run by tag. 

所有包含tag的测试用例都会被执行

-e --exclude tag *       Select test cases not to run by tag.

所有包含tag的测试用例都不会被执行

pybot -i smoke -e tbd xxx.robot

上面这段命令,会执行包含smoke的但不包含tbd的测试用例

2020年6月2日星期二

问题记录: jenkins +robot 报告处理失败

奇怪问题记录:
jenkins +robot 
生成结果报告提示
Robot results publisher started...
-Parsing output xml:
Done!
-Copying log files to build dir:
Failed!

在对应的目录可以看到生成的报告,但是在jenkins无法访问,这个是统计过程出现问题引起的吗?

2020年5月8日星期五

robotframe work 中teardown 的log位置

這個好奇怪,在testcase或者testsuit的入口位置,如下:之前自己默認認為這個log是時間順序的,所以擔心teardown 的執行和自己預期不一致
但是仔細看了一下run的time,是最後,只是log的位置處理到前面了:).  記錄一下,這個也不錯,清晰,只是不習慣這個,知道就好了



轉: robotframework sleep

可以內置使用Sleep



Pauses the test executed for the given time.

time may be either a number or a time string. Time strings are in a format such as 1 day 2 hours 3 minutes 4 seconds 5milliseconds or 1d 2h 3m 4s 5ms, and they are fully explained in an appendix of Robot Framework User Guide. Optional reason can be used to explain why sleeping is necessary. Both the time slept and the reason are logged.

Examples:

Sleep42
Sleep1.5
Sleep2 minutes 10 seconds
Sleep10sWait for a reply

轉: robotframework 內置變量

https://testerhome.com/topics/18492


  • 自动化变量 > 自动化变量在测试执行过程中可能值会变化,也有一些变量是在特定时期可用。
变量描述使用范围
${TEST NAME}当前测试用例的名称测试用例内
@{TEST TAGS}当前测试用的Tags测试用例内
${TEST DOCUMENTATION}当前测试用例的文档测试用例内
${TEST STATUS}当前测试用例的测试结果,PASS或FAILTest teardown
${TEST MESSAGE}当前测试用的的测试结果信息Test teatdown
${PREV TEST NAME}上一条测试用例的名称,如果没有则值为空任意
${PREV TEST STATUS}上一条测试用例的结果,如果没有则值为空任意
${PREV TEST MESSAGE}上一条测试用例的结果信息,如果没有则值为空任意
${SUITE NAME}当前测试集的全称任意
${SUITE SOURCE}当前测试集的绝对路径任意
${SUITE DOCUMENTATION}当前测试集的描述,可以通过Set Suite Documentation 修改任意
&{SUITE METADATA}当前测试集的METADATA,可以通过Set Suite Metadata修改任意
${SUITE STATUS}当前测试集的测试状态Suite teardown
${SUITE MESSAGE}当前测试集的测试状态信息Suite teardown
${KEYWORD STATUS}当前关键字的状态Keyword teardown
${KEYWORD MESSAGE}当前关键字的状态信息Keyword teardown
${LOG LEVEL}当前的日志级别任意
${OUTPUT FILE}output文件的绝对路径任意
${LOG FILE}log文件的绝对路径,如果没有则为None任意
${REPORT FILE}report文件的绝对路径,如果没有则为None任意
${DEBUG FILE}debug文件的绝对路径,如果没有则为None任意
${OUTPUT DIR}output文件夹的绝对路径任意

2020年4月28日星期二

robotframwork tuple 引用

官方標準解答是使用Convert To List
t.robot.txt                                                      
 17     BuiltIn.log     ${tu}
 18     BuiltIn.log     ${tl}
 19     ${c_tu}=     Convert To List    ${tu}
 20     BuiltIn.log     ${c_tu}
 21     BuiltIn.log     ${c_tu}[0]
 22 #    BuiltIn.log    ${ngtdp_server}
 23 #    BuiltIn.log    ${dic_web}
定義 t.py
  1 tu = ('fail', {'ip': 'pass'})
  2 tl = ['fail', {'ip': 'pass'}]


2019年3月19日星期二

robotframe的listener



参考:
https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/ExtendingRobotFramework/ListenerInterface.rst#listener-examples

说明:


robot 的listener可以在robot运行中监听当前运行test的内容:
 start.end.status 等,具体参见:

https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/ExtendingRobotFramework/ListenerInterface.rst#listener-version-3

这里区分robot2/3是不同的,

下面是官方的demo for robot3,测试通过了,现在想想可以解决修改testsuit name的问题,其他功能还有待发掘。不过这个listener现在感觉是robot运行过程中的一个对话监控者。
如果有其他辅助信息,可以使用它做其他的传导。

eg:


If the above example would be saved to, for example, :file:`PauseExecution.py` file, it could be used from the command line like this:
robot --listener path/to/PauseExecution.py tests.robot
The same example could also be implemented also using the newer listener version 3 and used exactly the same way from the command line.
"""Listener that stops execution if a test fails."""

ROBOT_LISTENER_API_VERSION = 3

def end_test(data, result):
    if not result.passed:
        print('Test "%s" failed: %s' % (result.name, result.message))
        raw_input('Press enter to continue.') #这个检测可以发现测试停止了,
     #说明listener 和robot是使用一个线程的,不是两个,这个要注意,但是listener中错误应是
     #被封装了,在robot运行中是不会看到listener的错误的:),留心不报错的代码执行问题。

The next example, which still uses Python, is slightly more complicated. 

Modifying execution and results

These examples illustrate how to modify the executed tests and suites as well as the execution results. All these examples require using the listener version 3.

Modifying executed suites and tests

Changing what is executed requires modifying the model object containing the executed `test suite <running.TestSuite_>`__or `test case <running.TestCase_>`__ objects passed as the first argument to start_suite and start_test methods. This is illustrated by the example below that adds a new test to each executed test suite and a new keyword to each test.
ROBOT_LISTENER_API_VERSION = 3

def start_suite(suite, result):
    suite.tests.create(name='New test')

def start_test(test, result):
    test.keywords.create(name='Log', args=['Keyword added by listener!'])

Trying to modify execution in end_suite or end_test methods does not work, simply because that suite or test has already been executed. Trying to modify the name, documentation or other similar metadata of the current suite or test in start_suite or start_test method does not work either, because the corresponding result object has already been created. Only changes to child tests or keywords actually have an effect.

2019年2月27日星期三

python2与python3并存时如果使用python3 的robot




[问题描述]

python2与python3并存时如果使用python3 的robot

[解决方式]

[root@lijie-120 tdp.detecttest]# whereis robot
robot: /usr/bin/robot
根据robot的脚本写了如下的robot3
[root@lijie-120 tdp.detecttest]# whereis robot3
robot3: /usr/bin/robot3

vim /usr/bin/robot3 中修改如下
#!/usr/bin/python36

之后调用robot3 --version 就ok了


2018年12月19日星期三

robotframework的Statistics by Suite显示内容问题


https://stackoverflow.com/questions/39119873/how-to-change-the-structure-of-output-xml-from-robot-framework-output

问题描述:
robotframe 的报告中 Statistics by Suite中每个格中只显示当前的test suit 或者 tag的name 不是全部的,如下笑脸部分:

结果:
当前的robot不可以,不可以

如下描述:
There is no way to modify the format of the output.xml file that was generated by robot. You have a couple of choices.
First, you can post-process output.xml with xslt or any other tool to transform it into whatever format you want. It's a very simple structure that is easy to parse.
Your second option is to ignore the output.xml and write your own using the listener interface. Through the listener interface you can get a callback for every suite, testcase and keyword where you can write your own output in whatever format you like.
【popexizhi:
方案一: 自己该output.xml 
方案二:  listener interface 这个还是第一次听说,看来可以试试
方案三: 我可以试试改改源码如下,嘻嘻,这个回头[next]

2018年11月29日星期四

No keyword with name "Set To Dictionary" found.



写成这样
 36     ${ta}    Create Dictionary     
 37     Set To Dictionary    ${ta}    a=b
还是提示
No keyword with name 'Set To Dictionary' found.


如下都没有介绍如何可以好,

https://stackoverflow.com/questions/29167928/getting-error-while-using-set-to-dictionary-keyword-in-robot-framework
https://github.com/robotframework/robotframework/issues/2320
https://stackoverflow.com/questions/29167928/getting-error-while-using-set-to-dictionary-keyword-in-robot-framework

最后改成这样吧
 33     ${waf_server_dic_tmp}=    Create Dictionary    ip=&{waf_server_dic}[ip]    port=${port}
 34     BuiltIn.log    ${waf_server_dic_tmp}  

ok了

【后记:
找到原因了是没有导入使用库的原因,加入如下就ok了
Library  Collections
看了一下源码,定义没有在BuildIn中,所以无法默认加载

2018年10月31日星期三

robotframe 嵌套字典引用---好纠结的使用方式啊


遇到的问题:
嵌套定义的字典,引用最内部的key提示无这个定义内容,如下:

KEYWORD ${test_ip}= = &{&{config_map}[${env_config}]}[tdp_ip]
15:36:49.003  FAIL   No keyword with name '&{&{config_map}[${env_config}]}[tdp_ip]' found.


当前的解决方式:

  1 *** Settings ***
  2 Variables    mapping_tdp.py
  3 *** Test Cases ***    
  4 testII      
  5     ${env_config}     Set Variable    dev
  6     Log    &{config_map}[${env_config}]
  7     &{deva}    Set Variable    &{config_map}[${env_config}]
  8     Log    ${deva}
  9     Log    &{deva}[tdp_ip]  



使用内层字典定义再次引用的方式

[popexizhi: 好吧我是来吐槽robotframe的,再次吐槽,真的不好用,看来要去社区提要求了,这种语法太不支持良好了:)]

2018年10月30日星期二

robotframework 导入类的命名--问题记录


https://robotframework-userguide-cn.readthedocs.io/zh_CN/latest/CreatingTestData/UsingTestLibraries.html#id3

使用库的路径

另一种导入库的方法是使用文件的路径来指定库. 类似于指定 资源文件和变量文件 的路径, 库的路径也被认为是相对于当前测试数据文件所在目录的(当然, 指定绝对路径也是可以的).
这种方式最大的好处是无需配置模块搜索路径.
如果库是一个文件, 则路径必须包含扩展名. 对Python库, 扩展名是 .py, 对Java库则是 .class 或 .java, 不过.class文件必须存在. 如果Python库是一个文件夹, 该路径最后必须有一个斜杠结尾(/).
下面的例子展示了几种不同的情况.
*** Settings ***
Library    PythonLibrary.py
Library    /absolute/path/JavaLibrary.java
Library    relative/path/PythonDirLib/    possible    arguments
Library    ${RESOURCES}/Example.class
该方法的缺陷是, Python类实现的 库名称必须和模块名一样. 此外, 使用 JAR包或者ZIP包发布的库不能使用这种方式.
[popexizhi:  这个库名称和模块名同名的要求,太坑了,还有别的方法导入类吗?这个还有潜在问题,如果有初始化类的参数如何使用啊????
]

2018年10月24日星期三

jenkins+robotframe Robot Framework log/report can be opened


[popexizhi:每次重启手动运行吧:)]
https://issues.jenkins-ci.org/browse/JENKINS-32118

For resolve your problem you must :
Connect on your jenkins url (http://[IP]:8080/)
Click on administer Jenkins
Click on consol jenkins
Copy this into the field and execute :
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;")

2018年10月23日星期二

哈哈来吐槽robotframe的参数问题



--variable 的使用问题

pass 的例子
# robot --outputdir test_use/ --variable tname:Hello test.txt
==============================================================================
Test                                                                          
==============================================================================
test                                                                  | PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output:  /root/test/tdp.detecttest/test_use/output.xml
Log:     /root/test/tdp.detecttest/test_use/log.html

Report:  /root/test/tdp.detecttest/test_use/report.html


err 的例子
# robot --outputdir test_use/ test.txt --variable tname:Hello 
[ ERROR ] Parsing '--variable' failed: Data source does not exist.


Try --help for usage information.

[popexizhi:
太坑了,对testcase文件的顺序这么敏感,你倒是help写明白啊,但是来看一下help

 94  -v --variable name:value *  Set variables in the test data. Only scalar
 95                           variables with string value are supported and name is
 96                           given without `${}`. See --escape for how to use
 97                           special characters and --variablefile for a more
 98                           powerful variable setting mechanism.
 99                           Examples: 
100                           --variable str:Hello       =>  ${str} = `Hello`
101                           -v hi:Hi_World -E space:_  =>  ${hi} = `Hi World`
102                           -v x: -v y:42              =>  ${x} = ``, ${y} = `42`

]

2018年8月29日星期三

fitness与robotframework的对比

fitness

  • 优点
    • wiki的testcase管理和test都很方便
    • history的查看很赞
  • 与robotframework对比-少的部分
    • testcase的table中如何添加测试用例说明?
    • table中测试文件的当前路径是什么,如何使用相对位置?
    • 底层访问时,在参数构造时,如何与忽略参数处理?与现在的code合成
      • [popexizhi]这个是代码的设计问题吧?
    • 每个testcase缺少单独的访问时间,这个在异步请求或长时间超时问题上是个很有效的功能
    • 如何在gitlab中保存testcase?  

2018年4月9日星期一

转:jenkins服务器上要支持robotframkework



参考:http://www.foryouslg.com/blog/13/118/
[popexizhi:原文写的很死板,其实安装了robotframkework 的jenkins 插件后
在构建后操作中选择 Publish Robot Framework test results,配置其中的output路径为html的输出结果路径就可以了。
注意: 这个位置与构建过程的脚本中参数不能通用,要使用变量只能用全局变量或者构建参数中的变量
]

2017年10月25日星期三

robotframe 内嵌关键字的用法补遗VI



http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20If%20Any%20Critical%20Tests%20Failed


&{clist}= Create Dictionary key=key1 value=value1
logname ${clist}
Log ${clist}
PS: 注意一点 字典定义时使用&, 打印引用时使用$
Create Dictionary*items
Creates and returns a dictionary based on the given items.
Items are typically given using the key=value syntax same way as &{dictionary} variables are created in the Variable table. Both keys and values can contain variables, and possible equal sign in key can be escaped with a backslash like escaped\=key=value. It is also possible to get items from existing dictionaries by simply using them like &{dict}.
Alternatively items can be specified so that keys and values are given separately. This and the key=value syntax can even be combined, but separately given items must be first.
If same key is used multiple times, the last value has precedence. The returned dictionary is ordered, and values with strings as keys can also be accessed using a convenient dot-access syntax like ${dict.key}.
Examples:
&{dict} = Create Dictionary key=value foo=bar # key=value syntax Should Be True ${dict} == {'key': 'value', 'foo': 'bar'} &{dict2} = Create Dictionary key value foo bar # separate key and value Should Be Equal ${dict} ${dict2} &{dict} = Create Dictionary ${1}=${2} &{dict} foo=new # using variables Should Be True ${dict} == {1: 2, 'key': 'value', 'foo': 'new'} Should Be Equal ${dict.key} value # dot-access
This keyword was changed in Robot Framework 2.9 in many ways:
Moved from Collections library to BuiltIn. Support also non-string keys in key=value syntax. Returned dictionary is ordered and dot-accessible. Old syntax to give keys and values separately was deprecated, but deprecation was later removed in RF 3.0.1.
@{items}= Create List a b cCreate List*items
Returns a list containing given items.
The returned list can be assigned both to ${scalar} and @{list} variables.
Examples:
@{list} = Create List a b c ${scalar} = Create List a b c ${ints} = Create List ${1} ${2} ${3}
${py}= Evaluate random.randint(0, sys.maxint) modules=random, sys
Log ${py}
PS: 可以直接执行python模块和方法,不错很好用
Evaluateexpression,modules=None,namespace=None
Evaluates the given expression in Python and returns the results.
expression is evaluated in Python as explained in Evaluating expressions.
modules argument can be used to specify a comma separated list of Python modules to be imported and added to the evaluation namespace.
namespace argument can be used to pass a custom evaluation namespace as a dictionary. Possible modules are added to this namespace. This is a new feature in Robot Framework 2.8.4.
Variables used like ${variable} are replaced in the expression before evaluation. Variables are also available in the evaluation namespace and can be accessed using special syntax $variable. This is a new feature in Robot Framework 2.9 and it is explained more thoroughly in Evaluating expressions.
Examples (expecting ${result} is 3.14):
${status} = Evaluate 0 < ${result} < 10 # Would also work with string '3.14' ${status} = Evaluate 0 < $result < 10 # Using variable itself, not string representation ${random} = Evaluate random.randint(0, sys.maxint) modules=random, sys ${ns} = Create Dictionary x=${4} y=${2} ${result} = Evaluate x*10 + y namespace=${ns}
=>
${status} = True
${random} =
${result} = 42
:FOR ${it} IN @{items}
\ Run Keyword If '${it}'=='a' Exit For Loop
\ Log ${it}
Exit For Loop
Stops executing the enclosing for loop.
Exits the enclosing for loop and continues execution after it. Can be used directly in a for loop or in a keyword that the loop uses.
Example:
:FOR ${var} IN @{VALUES} Run Keyword If '${var}' == 'EXIT' Exit For Loop Do Something ${var}
See Exit For Loop If to conditionally exit a for loop without using Run Keyword If or other wrapper keywords.
:FOR ${it} IN @{items}
\ Exit For Loop If '${it}'=='b'
\ Log ${it}
Exit For Loop Ifcondition
Stops executing the enclosing for loop if the condition is true.
A wrapper for Exit For Loop to exit a for loop based on the given condition. The condition is evaluated using the same semantics as with Should Be True keyword.
Example:
:FOR ${var} IN @{VALUES} Exit For Loop If '${var}' == 'EXIT' Do Something ${var}
New in Robot Framework 2.8.
Fail test failFailmsg=None, *tags
Fails the test with the given message and optionally alters its tags.
The error message is specified using the msg argument. It is possible to use HTML in the given error message, similarly as with any other keyword accepting an error message, by prefixing the error with *HTML*.
It is possible to modify tags of the current test case by passing tags after the message. Tags starting with a hyphen (e.g. -regression) are removed and others added. Tags are modified using Set Tags and Remove Tags internally, and the semantics setting and removing them are the same as with these keywords.
Examples:
Fail Test not ready # Fails with the given message. Fail *HTML*Test not ready # Fails using HTML in the message. Fail Test not ready not-ready # Fails and adds 'not-ready' tag. Fail OS not supported -regression # Removes tag 'regression'. Fail My message tag -t* # Removes all tags starting with 't' except the newly added 'tag'.
See Fatal Error if you need to stop the whole test execution.
Support for modifying tags was added in Robot Framework 2.7.4 and HTML message support in 2.8.
Fatal Error test faial Error Fatal Errormsg=None
${count}= Get Count 2aa3 aGet Countitem1, item2
Returns and logs how many times item2 is found from item1.
This keyword works with Python strings and lists and all objects that either have count method or can be converted to Python lists.
Example:
${count} = Get Count ${some item} interesting value Should Be True 5 < ${count} < 10
${num}= Get Length aaadddsdfadsdGet Lengthitem
Returns and logs the length of the given item as an integer.
The item can be anything that has a length, for example, a string, a list, or a mapping. The keyword first tries to get the length with the Python function len, which calls the item's __len__ method internally. If that fails, the keyword tries to call the item's possible length and size methods directly. The final attempt is trying to get the value of the item's length attribute. If all these attempts are unsuccessful, the keyword fails.
Examples:
${length} = Get Length Hello, world! Should Be Equal As Integers ${length} 13 @{list} = Create List Hello, world! ${length} = Get Length ${list} Should Be Equal As Integers ${length} 2
See also Length Should Be, Should Be Empty and Should Not Be Empty.
&{all libs}= Get library instance all=True
Log Many &{all libs}
? PS:还是不太明白这个方法返回的内容,是全部的内置导入的类吗?
以上代码打印结果如下:
KEYWORD BuiltIn . Log Many &{all libs}
Documentation:
Logs the given messages as separate entries using the INFO level.
Start / End / Elapsed: 20171026 12:30:55.955 / 20171026 12:30:55.957 / 00:00:00.002
12:30:55.956 INFO Reserved=
12:30:55.956 INFO Demo=
12:30:55.956 INFO OperatingSystem=
12:30:55.957 INFO BuiltIn=
12:30:55.957 INFO Easter=
Get Library Instancename=None, all=False
Returns the currently active instance of the specified test library.
This keyword makes it easy for test libraries to interact with other test libraries that have state. This is illustrated by the Python example below:
from robot.libraries.BuiltIn import BuiltIn

def title_should_start_with(expected):
seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
title = seleniumlib.get_title()
if not title.startswith(expected):
raise AssertionError("Title '%s' did not start with '%s'"
% (title, expected))
It is also possible to use this keyword in the test data and pass the returned library instance to another keyword. If a library is imported with a custom name, the name used to get the instance must be that name and not the original library name.
If the optional argument all is given a true value, then a dictionary mapping all library names to instances will be returned. This feature is new in Robot Framework 2.9.2.
Example:
&{all libs} = Get library instance all=True
${time} = Get Time
${secs} = Get Time epoch
${year} = Get Time return year
${yyyy} ${mm} ${dd} = Get Time year,month,day
@{time} = Get Time year month day hour min sec
${y} ${s} = Get Time seconds and year
Log Many ${time} ${secs} ${year} ${yyyy} ${mm} ${dd} @{time} ${y} ${s}
Get Timeformat=timestamp,time_=NOW
Returns the given time in the requested format.
NOTE: DateTime library added in Robot Framework 2.8.5 contains much more flexible keywords for getting the current date and time and for date and time handling in general.
How time is returned is determined based on the given format string as follows. Note that all checks are case-insensitive.
1) If format contains the word epoch, the time is returned in seconds after the UNIX epoch (1970-01-01 00:00:00 UTC). The return value is always an integer.
2) If format contains any of the words year, month, day, hour, min, or sec, only the selected parts are returned. The order of the returned parts is always the one in the previous sentence and the order of words in format is not significant. The parts are returned as zero-padded strings (e.g. May -> 05).
3) Otherwise (and by default) the time is returned as a timestamp string in the format 2006-02-24 15:08:31.
By default this keyword returns the current local time, but that can be altered using time argument as explained below. Note that all checks involving strings are case-insensitive.
1) If time is a number, or a string that can be converted to a number, it is interpreted as seconds since the UNIX epoch. This documentation was originally written about 1177654467 seconds after the epoch.
2) If time is a timestamp, that time will be used. Valid timestamp formats are YYYY-MM-DD hh:mm:ss and YYYYMMDD hhmmss.
3) If time is equal to NOW (default), the current local time is used. This time is got using Python's time.time() function.
4) If time is equal to UTC, the current time in UTC is used. This time is got using time.time() + time.altzone in Python.
5) If time is in the format like NOW - 1 day or UTC + 1 hour 30 min, the current local/UTC time plus/minus the time specified with the time string is used. The time string format is described in an appendix of Robot Framework User Guide.
Examples (expecting the current local time is 2006-03-29 15:06:21):
${time} = Get Time ${secs} = Get Time epoch ${year} = Get Time return year ${yyyy} ${mm} ${dd} = Get Time year,month,day @{time} = Get Time year month day hour min sec ${y} ${s} = Get Time seconds and year
=>
${time} = '2006-03-29 15:06:21'
${secs} = 1143637581
${year} = '2006'
${yyyy} = '2006', ${mm} = '03', ${dd} = '29'
@{time} = ['2006', '03', '29', '15', '06', '21']
${y} = '2006'
${s} = '21'
Examples (expecting the current local time is 2006-03-29 15:06:21 and UTC time is 2006-03-29 12:06:21):
${time} = Get Time 1177654467 # Time given as epoch seconds ${secs} = Get Time sec 2007-04-27 09:14:27 # Time given as a timestamp ${year} = Get Time year NOW # The local time of execution @{time} = Get Time hour min sec NOW + 1h 2min 3s # 1h 2min 3s added to the local time @{utc} = Get Time hour min sec UTC # The UTC time of execution ${hour} = Get Time hour UTC - 1 hour # 1h subtracted from the UTC time
=>
${time} = '2007-04-27 09:14:27'
${secs} = 27
${year} = '2006'
@{time} = ['16', '08', '24']
@{utc} = ['12', '06', '21']
${hour} = '11'
Support for UTC time was added in Robot Framework 2.7.5 but it did not work correctly until 2.7.7.