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

Popular Categories





Get response time of a webpage

0 votes
5,279 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

0 votes
1 answer 174 views
+2 votes
1 answer 1,214 views
+1 vote
1 answer 2,229 views
+5 votes
7 answers 14,583 views
+1 vote
1 answer 541 views
+11 votes
1 answer 121 views
+13 votes
1 answer 117 views

Not a Member yet?

Ask to Folks Login

My Account
433 Folks are online
38 members and 395 guest online
Your feedback is highly appreciated