Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script src="jquery-2.1.1.min.js" type="text/javascript"></script>
- <title>CasperJS Automated Testing Utility</title>
- </head>
- <center>
- <body>
- <div id="mainContent">
- <p>Welcome to the CasperJS Automated Testing Utility</p>
- <br>
- <button id="button_AJAX">Run casperJS</button>
- <button id="button_STOP" onclick="myStopFunction()">Stop casperJS</button>
- </div>
- <br>
- <div id="loading"></div>
- <script type="text/javascript">
- $('#button_AJAX').click(function doStuff() {
- // add loading image to div
- $('#loading').html('<img src="rays.gif"><br><i>Web harvesting in progress; please wait for test results.</i>');
- var ajaxTime= new Date().getTime();
- var today = new Date();
- var dd = today.getDate();
- var mm = today.getMonth()+1; //January is 0!
- var yyyy = today.getFullYear();
- // Run ajax request
- $.ajax({
- type: "GET",
- dataType: "text",
- url: "phpwithCasperJS.php",
- // AJAX success
- success: function (data) {
- $('#loading').html(data);
- // Total time and date / time of AJAX completion
- var totalTime = new Date().getTime()-ajaxTime;
- window.alert = function(message) {
- var output = document.getElementById('loading'),
- newTextContainer = document.createElement('p'),
- text = document.createTextNode(message);
- newTextContainer.appendChild(text);
- output.appendChild(newTextContainer);
- if(dd<10) {
- dd='0'+dd
- }
- if(mm<10) {
- mm='0'+mm
- }
- today = mm+'/'+dd+'/'+yyyy;
- }
- alert("Test completed in " + totalTime + " ms, on " + today);
- }
- });
- timeout = setTimeout(doStuff,3000000); });
- $("#button_AJAX").click(function() {$("#button_AJAX").text("CasperJS Executed");});
- $("#button_STOP").click(function() {$("#button_AJAX").text("Run casperJS");});
- function myStopFunction() {
- clearTimeout(timeout);
- }
- </script>
- </div>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement