Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="jquery-2.1.1.min.js" type="text/javascript"></script>
  5. <title>CasperJS Automated Testing Utility</title>
  6. </head>
  7. <center>
  8. <body>
  9. <div id="mainContent">
  10. <p>Welcome to the CasperJS Automated Testing Utility</p>
  11. <br>
  12. <button id="button_AJAX">Run casperJS</button>
  13. <button id="button_STOP" onclick="myStopFunction()">Stop casperJS</button>
  14. </div>
  15. <br>
  16. <div id="loading"></div>
  17. <script type="text/javascript">
  18. $('#button_AJAX').click(function doStuff() {
  19. // add loading image to div
  20. $('#loading').html('<img src="rays.gif"><br><i>Web harvesting in progress; please wait for test results.</i>');
  21. var ajaxTime= new Date().getTime();
  22. var today = new Date();
  23. var dd = today.getDate();
  24. var mm = today.getMonth()+1; //January is 0!
  25. var yyyy = today.getFullYear();
  26. // Run ajax request
  27. $.ajax({
  28. type: "GET",
  29. dataType: "text",
  30. url: "phpwithCasperJS.php",
  31. // AJAX success
  32. success: function (data) {
  33. $('#loading').html(data);
  34. // Total time and date / time of AJAX completion
  35. var totalTime = new Date().getTime()-ajaxTime;
  36. window.alert = function(message) {
  37. var output = document.getElementById('loading'),
  38. newTextContainer = document.createElement('p'),
  39. text = document.createTextNode(message);
  40. newTextContainer.appendChild(text);
  41. output.appendChild(newTextContainer);
  42. if(dd<10) {
  43. dd='0'+dd
  44. }
  45. if(mm<10) {
  46. mm='0'+mm
  47. }
  48. today = mm+'/'+dd+'/'+yyyy;
  49. }
  50. alert("Test completed in " + totalTime + " ms, on " + today);
  51. }
  52. });
  53. timeout = setTimeout(doStuff,3000000); });
  54. $("#button_AJAX").click(function() {$("#button_AJAX").text("CasperJS Executed");});
  55. $("#button_STOP").click(function() {$("#button_AJAX").text("Run casperJS");});
  56. function myStopFunction() {
  57. clearTimeout(timeout);
  58. }
  59. </script>
  60. </div>
  61. </center>
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement