Understanding elapsed time in app testing

I’m a new user of Katalon Studio. I was testing a mobile application - “Gaana.”
I performed the following steps:

  1. Created a set of actions for testing, which include:
    a. Start the application
    b. Click on a button that opens a new activity
    c. Again click on a button which plays a video
    d. Close the application

  2. Checked the log viewer which shows elapsed time for each action.

I wanted to know the time difference after tapping (Step b) and the next activity has completely loaded so that the action can be performed. Could you please help?

The code is as follows:

Mobile.startApplication('pathtoapk',false)
Mobile.waitForElementPresent(findTestObject('android.widget.TextView0 - Buzz'), 0, FailureHandling.STOP_ON_FAILURE)
Mobile.tap(findTestObject('android.widget.TextView0 - Buzz'), 0)
Mobile.waitForElementPresent(findTestObject('android.view.View0'), 0, FailureHandling.STOP_ON_FAILURE)
Mobile.tap(findTestObject('android.view.View0'), 0)
Mobile.closeApplication()

Hi @mohit.singh9512,

Could you be more specific about your question? /=)

I’ve edited the question.
Sorry for the inconvenience.

Hi @mohit.singh9512,

To measure the time between each action, you could use some java library like StopWatch.

For example:

import org.apache.commons.lang3.time.StopWatch

StopWatch watch = StopWatch.createStarted()

Mobile.waitForElementPresent(findTestObject('Application/android.widget.TextView - Graphics'), GlobalVariable.G_Timeout)

println " - - - "
println "wait action take: " + watch.getTime() + "ms"
println " - - - "

watch.split()
Mobile.tap(findTestObject('Application/android.widget.TextView - Graphics'), GlobalVariable.G_Timeout)

println " - - - "
println "tap action take: " + (watch.getTime() - watch.getSplitTime()) + "ms"
println " - - - "

watch.split()
Mobile.tap(findTestObject('Application/android.widget.TextView - Graphics'), GlobalVariable.G_Timeout)

println " - - - "
println "second tap action take: " + (watch.getTime() - watch.getSplitTime()) + "ms"
println " - - - "

watch.stop()

println " - - - "
println "total time: " + watch.getTime() + "ms"
println " - - - "

And then check the result in the Console tab /=)

image

Thank you for your response.
However, I am looking for activity loading time.
Let me put a scenario:

  1. An application has started
  2. Perform a button tap at time t1.
  3. The tap operation opens a new activity.
  4. The activity makes a few network calls and loading completes at time t2.

I would like to know the time t1 and t2.
Currently, the tap operation takes a very long time for certain elements. Hence, I am not able to use the time difference viz. (t2 - t1) as suggested in the solution.
Please suggest some way to achieve this.

Hi @mohit.singh9512,

As I understand, you want to know how long your “few network calls” take. If that so, you could use Mobile.waitForElementPresent(...) to wait for something that will be present after your “few network calls” done running.

import org.apache.commons.lang3.time.StopWatch

Mobile.startApplication('pathtoapk', false)
Mobile.waitForElementPresent(findTestObject('android.widget.TextView0 - Buzz'), 0, FailureHandling.STOP_ON_FAILURE)
Mobile.tap(findTestObject('android.widget.TextView0 - Buzz'), 0)

StopWatch watch = StopWatch.createStarted()

// Few network calls are running...

Mobile.waitForElementPresent(findTestObject('android.view.View0'), 0, FailureHandling.STOP_ON_FAILURE)

// Few network calls have been done and the `android.view.View0` is now present!

watch.stop()

println " - - - "
println "Few network calls take: " + watch.getTime() + "ms"
println " - - - "

Mobile.tap(findTestObject('android.view.View0'), 0)
Mobile.closeApplication()

~ Hope this is what you wish… /=)

1 Like

Thanks for your answer. It worked like a charm.

1 Like