Hey there! any question in your mind? Ask It Now!.

Popular Categories





Get response time of a webpage

0 votes
4,022 views
asked in Software Testing by Gaurav
I want to automate this process of getting response time of a webpage in every 3 hour. You can explain me in java , php , python or may be in selenium tool or without it .

1 Answer

0 votes
answered by Sidhant
edited by Bhartesh
Hi Gaurav,

It's a commonly used scenario to test response time and throw the alert in case of high response time. I used simple PHP code for the same.

you can use this function to get response time.

<?php

function getResponseTime($url){
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  if(curl_exec($ch)){
  $info = curl_getinfo($ch);
    // echo 'Took ' . $info['total_time'] . ' seconds to transfer a request to ' . $info['url'].$_GET['env'];
    $rs_time = $info['total_time'];
  }
  return $rs_time;
}

   $responsetime = getResponseTime("url");
   echo $responsetime;


?>

This is a simple implementation and you can set up a corn and schedule this file as per your need.

In selenium: You can get an URL and on the basis of an element present in the web page can log the time. But it's not a good solution for checking response time.

Related Questions

+1 vote
1 answer 536 views

Not a Member yet?

Ask to Folks Login

My Account
133 Folks are online
0 members and 133 guest online
Your feedback is highly appreciated