-1

I am trying to automate my performance testing scenario on two different browser Edge and Chrome, since both scripts supports the JavaScript API's for performance.

The problem I am facing is my scenarios are different from one another, but this happen on the same session of web Browser.

For example, I need to measure the response time on opening a form which is first scenario, the second scenario would be response time taken for a form to save, both are two different scenarios but use same session of browser.

I am trying to use the following code once my first scenario is done

window.performance.timing.responseStart - window.performance.timing.responseEnd 

here I get proper time 8 ms, post this I try to fill and save form which is my second scenario, and verify the response time like the above, I still get 8 ms which is not validate as the actual time took to save and reload the new form is more than 8 ms. When I check the individual response start and end time, they remain same for the entire session.

I want to calculate different response time for the form on save and reload. Is this feasible in First place? If so what is the better approach?

TylerH
  • 20,799
  • 66
  • 75
  • 101
user2861354
  • 41
  • 1
  • 8

1 Answers1

0

With reference to this article, we can see that:

PerformanceTiming.responseStart: When the browser received the first byte of the response, from the server from a cache, or from a local resource.

PerformanceTiming.responseEnd: When the browser received the last byte of the response, or when the connection is closed if this happened first, from the server, the cache, or from a local resource.

So, according to above properties we could get the total time taken to download the webpage from the server.

More detail about the process timing, I suggest you check the PerformanceTiming interface and Measure Web Page Performance Using JavaScript.

Besides, if you want to calculate the response time for the form save and reload, I suggest you could also try to use Date object to calculate the time, like this and this thread.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30