Rakesh
Rakesh

Reputation: 1575

How to calculate overall wait time that application took during test execution?

I have created common keyword for wait functionality as below

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}

I have called this "Wait_Function" / "Wait_Function_For_Text " at places where the application takes time to load the element as below:

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

Similarly, this common Wait keywords were used in many test cases(Function C,Function D,...)

Now, i want to calculate the wait time for each test case and also overall cumulative wait time for verifying performance.

I would need output like

 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)

Any input/suggestions would be helpful.

Upvotes: 2

Views: 339

Answers (1)

Petr Hudeček
Petr Hudeček

Reputation: 1763

When you run a robot suite, it produces an XML file. Each keyword, including Function A and Function B, is there as an XML element. For example:

<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>

Note the last child, status. It has two timestamps: starttime and endtime.

To get the cumulative time taken by your functions, you can write a script or a program that processes this XML file, calculates the difference between endtime and starttime for each instance of the keyword Function A and Function B and calculate a sum of those differences.

Upvotes: 1

Related Questions