【问题标题】:How to calculate overall wait time that application took during test execution?如何计算应用程序在测试执行期间的总体等待时间?
【发布时间】:2018-03-17 05:00:44
【问题描述】:

我为等待功能创建了通用关键字,如下所示

Wait_Function
    [Arguments]    ${Element}
    Wait Until Keyword Succeeds     120s     2s    Element Should Be Visible      ${Element}

Wait_Function_For_Text
    [Arguments]    ${Element}    ${Text}
    Wait Until Keyword Succeeds     120s     2s    Element Should Contain      ${Element}    ${Text}

我在应用程序需要时间加载元素的地方称之为“Wait_Function”/“Wait_Function_For_Text”,如下所示:

Function A
    Click Element    ${Add}
    Wait_Function     ${Save}
    Click Element      ${Save}
    Wait_Function     ${Home_Icon}

Function B
    Scroll Element Into View    ${Add}
    Wait_Function     ${Add}
    Click Element      ${Add}
    Wait_Function_For_Text    id=SuccessMsg      User added successfully

同样,这个常见的 Wait 关键字被用于许多测试用例(Function C,Function D,...)

现在,我想计算每个测试用例的等待时间以及验证性能的总体累积等待时间。

我需要像这样的输出

 Wait time for Function A:        00:00:01:750 (1 sec 750 ms)
 Wait time for Function B:        00:00:00:350 (350 ms)
 Overall Cumulative Wait time:    00:00:02:100 (2 sec 100 ms)

任何意见/建议都会有所帮助。

【问题讨论】:

    标签: robotframework


    【解决方案1】:

    当您运行机器人套件时,它会生成一个 XML 文件。每个关键字(包括 Function A 和 Function B)都作为 XML 元素存在。例如:

    <kw library="BuiltIn" name="Get Time">
    <doc>Returns the given time in the requested format.</doc>
    <arguments>
    <arg>year month day</arg>
    </arguments>
    <assign>
    <var>${year}</var>
    <var>${month}</var>
    <var>${day}</var>
    </assign>
    <msg level="INFO" timestamp="20180315 17:22:00.692">${year} = 2018</msg>
    <msg level="INFO" timestamp="20180315 17:22:00.692">${month} = 03</msg>
    <msg level="INFO" timestamp="20180315 17:22:00.693">${day} = 15</msg>
    <status endtime="20180315 17:22:00.693" starttime="20180315 17:22:00.690" status="PASS"></status>
    </kw>
    

    注意最后一个孩子status。它有两个时间戳:starttimeendtime

    要获得函数所用的累积时间,您可以编写一个脚本或程序来处理此 XML 文件,计算关键字 Function A 和 Function B 的每个实例的 endtimestarttime 之间的差异,然后计算这些差异的总和。

    【讨论】:

    • 伟大的观察彼得!!!使用 Robot Framework 有一段时间了,但真的很怀念!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-29
    • 2014-07-13
    • 2015-10-25
    • 2018-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多