Recommend this
on Google+

Recommend this
on Google+

Wednesday, October 17, 2012

A test automation framework to fit in an existing manual-test-suite…

TestDriver.html web page source code

<!DOCTYPE HTML> <html> <head> <title>QA Automation Driver</title> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <!-- /**** Chunk logging: ============== 1. summarizedResult to be flushed-out for every 50 testcases, so as to prevent memory leaks, or out-of-memory conditions. 2. individualCaseResult() appends each testcase result to the buffer-summarizedResult. 3. ****/ --> <!-- 04th April 2012 - Commenting styling for testing purpose. Setting display and visibility of firstFrame is resulting in failure of few modules. --> <style type="text/css"> #secondFrame,#thirdFrame,#fourthFrame,#fifthFrame,#sixthFrame { display: none; visibility: hidden; } #testProgress { height: 100%; width: 100%; vertical-align: middle; text-align: center; display: block; } #pbInfoTable { display: table-row-group; height: 66%; width: 80%; vertical-align: middle; text-align: justify; } #pbInfoTable tr { text-align: center; vertical-align: middle; } #pbar {

padding: 5% 5% 5% 5%; } img { height: 50%; } </style> <link rel="stylesheet" type="text/css" href="Automated/styles/testheaders.css"> <script type="text/javascript" language="javascript" src="Automated/scripts/PostTestResults.js"></script> <script type="text/javascript" language="javascript"> /* 03rd April 2012 - Modifying for jQuery specific test cases. As cases are already automated using QUnit frame work. We are directly loading the individual test modules (not test cases) into testdriver and capturing the logs. */ var rtp = "Automated/resources/qunit_remote/file/jquery-mobile/tests/unit/"; /** * Commented below line of code in order to set serverURL relatively refer to Logtestresults.php. * Modified on 13th Dec 2011 **/ //serverURL = "http://iop4.nokia-boston.com/users/browser/tests/sr/gcf_new/Automated/resources/Logtestresults.php"; serverURL = "./Automated/resources/Logtestresults.php"; var summarizedResult = ''; var testEndResult; var passCount = failCount = skipCount = 0; var ticker = -1; /* 03rd April 2012 - Modifying to use only one iframe */ var framesLeft = 1; /* 03rd April 2012 - Creating an extra variable -- currentSession -- specifically in purview of running jQuery testsuite; as, session is required to be maintained explicitly by the testsuite for logging purpose. */ var currentSession = getTimeStamp(); //currentSession = "kcomkar"; /* 03rd April 2012 - Modifying for jQuery specific test cases. As cases are already automated using QUnit frame work. We are directly loading the individual test modules (not test cases) into testdriver and capturing the logs. Hence Array - tests contain the references to test module pages instead of individual test cases. As session is required and maintained across the testsuite execution session is parameterized expicitly for each test module. Also, for logging purposes qunit_remote/index.php has to be called before starting test suite execution and at the end of the execution. Begining: ~/qunit_remote/index.php?action=init&session=<<session>>

End : qunit_remote/index.php?action=end&session=<<session>>&output=raw 'action' parameter is self explainatory and when 'output' is set to 'raw'; a consolidated log for the testmodules executed in current session (specified by 'session') will be generated and rendered in XML format. */ /* 03rd April 2012 - Explicitly defining variables beginTimeStamp and endTimeStamp to hold the begin timestamp */ var beginTimeStamp = null; var endTimeStamp = null; /* 03rd April 2012 - Explicitly defining a variable logFilePrefix to hold the log filename. As result log is not posted using PostTestResults.js; had to define in the testdriver itself. This is directly parameterized along with index.php at the end of testsuite. */ /* 27th April 2012 - Removing timestamp info from log file prefix */ //var logFilePrefix = currentSession+"_"+querystring('buildNum')+querystring('mode')+'_'+querystring('type')+"_"+querystring('feature')+"_"+"results"; var logFilePrefix = querystring('buildNum')+"_"+querystring('mode')+'_'+querystring('type')+"_"+querystring('feature')+"_"; var tests = new Array("../../../../index.php?action=init&session="+currentSession, "page/index.html?session="+currentSession, "navigation/index.html?session="+currentSession, "buttonMarkup/index.html?session="+currentSession, "checkboxradio/index.html?session="+currentSession, "collapsible/index.html?session="+currentSession, "controlgroup/index.html?session="+currentSession, "core/index.html?session="+currentSession, "degradeInputs/index.html?session="+currentSession, "dialog/index.html?session="+currentSession, "event/index.html?session="+currentSession, "fieldContain/index.html?session="+currentSession, "fixedToolbar/index.html?session="+currentSession, "init/index.html?session="+currentSession, "listview/index.html?session="+currentSession, "media/index.html?session="+currentSession, "navbar/index.html?session="+currentSession, "button/index.html?session="+currentSession, "page-sections/index.html?session="+currentSession, "select/index.html?session="+currentSession, "slider/index.html?session="+currentSession, "support/index.html?session="+currentSession

"textinput/index.html?session="+currentSession,

Uncaught SyntaxError: Unexpected string

"widget/index.html?session="+currentSession, "zoom/index.html?session="+currentSession); var failureList = new Array(); var skipList = new Array(); function incrementPassCount()

{ passCount++; } function incrementFailCount() { failCount++; } function incrementSkipCount() { skipCount++; } //=========================================== START SERIAL LOAD ======================================================// function loadFirstSet() { /* 03rd April 2012 - Modifying to use only one iframe. It is observed that using a # value results in an unexpected behavior, as jQuert testsuite implicitly is using # values for executing test cases. Removing # values to avoid such conflicts. */ document.getElementById("firstFrame").setAttribute("src", rtp + tests[++ticker]); //document.getElementById("firstFrame").setAttribute("src", rtp + tests[++ticker] + "#firstFrame"); //document.getElementById("secondFrame").setAttribute("src", rtp + tests[++ticker] + "#secondFrame"); //document.getElementById("thirdFrame").setAttribute("src", rtp + tests[++ticker] + "#thirdFrame"); //document.getElementById("fourthFrame").setAttribute("src", rtp + tests[++ticker] + "#fourthFrame"); //document.getElementById("fifthFrame").setAttribute("src", rtp + tests[++ticker] + "#fifthFrame"); //document.getElementById("sixthFrame").setAttribute("src", rtp + tests[++ticker] + "#sixthFrame"); } function loadNextTest(destFrame) { destFrame = "firstFrame"; if (ticker < (tests.length - 1)) { ticker++; /* 03rd April 2012 - Modifying to use only one iframe removing #firstFrame*/ document.getElementById(destFrame).setAttribute("src", rtp + tests[ticker]); } else { framesLeft--; if (framesLeft == 0) { //console.log('=============================================================================RESULT======================================================='); //console.log('PASS :' + passCount); //console.log('FAIL :' + failCount); //console.log('SKIP :' + skipCount); console.log('=========================================================================================================================================='); try

{ var newLine='\r\n'; document.getElementById("complete").innerHTML="Completed"; var now = new Date() var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); endTimeStamp = hour+":"+minute+":"+second; /* 03rd April 2012 - Commenting below lines of code as log generation code in jQuery testsuite has been used. */ //testEndResult= newLine+"Totals: "+passCount+" passed, "+failCount+" failed, "+skipCount+" skipped"+newLine+"********* Finished testing of jQuery *********"+hour+":"+minute+":"+second; //postResults(summarizedResult + testEndResult); /* 03rd April 2012 - Loading index.php with 'action' - 'end' and 'output' - 'text'; indicating all the required modules are executed and logs are requested in 'text' format. Suitable changes are made to 'qur_engine.php', which is used in 'index.php' for log generation. */ document.getElementById(destFrame).setAttribute("src", "./Automated/resources/qunit_remote/index.php?action=end&output=text&session="+currentSession+"&fileName="+logFilePrefix+"&beginTime="+beginTimeStamp+"&endTime="+endTimeStamp); } catch (serverLogErr) { console.error('Exception during creating log strings.\n.Details:\t' + serverLogErr); console.log('Server log failed.\n.Details:\t' + serverLogErr); } /* 03rd April 2012 - Commenting below lines of code as log generation code in jQuery testsuite has been used. */ //setLogFileLocation("./Results/"); //document.getElementById("firstFrame").setAttribute("src", rtp + "resources/log_results.txt"); } } /* 03rd April 2012 - Including call to notifyProgress here. */ notifyProgress(); } //=========================================== END SERIAL LOAD ======================================================// //=========================================== START SETUP ENVIRONMENT===============================================// function setupEnvironment() { var now= new Date() var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); /* 03rd April 2012 - Explicitly declared a variable to hold the begin timestamp */ beginTimeStamp = hour+":"+minute+":"+second; summarizedResult = "************ Start GCF Test ************"+hour+":"+minute+":"+second; loadFirstSet(); }

//=========================================== END SETUP ENVIRONMENT===============================================//

function timedEvent()

{

if (ticker < tests.length)

{

ticker++;

document.getElementById("middleLevel").setAttribute("src", rtp + tests[ticker]);

removeJunk();

}

else

{

console.log('=============================================================================RESULT=======================================================');

console.log('PASS :' + passCount);

console.log('FAIL :' + failCount);

console.log('SKIP :' + skipCount);

console.log('==========================================================================================================================================');

try

{

var newLine='\r\n';

var now = new Date()

var hour = now.getHours();

var minute = now.getMinutes();

var second = now.getSeconds();

testEndResult= newLine+"Totals: "+passCount+" passed, "+failCount+" failed, "+skipCount+" skipped"+newLine+"********* Finished testing of jQuery *********"+hour+":"+minute+":"+second;;

postResults(summarizedResult + testEndResult);

}

catch (serverLogErr)

{

console.error('Exception during creating log strings.\n.Details:\t' + serverLogErr);

console.log('Server log failed.\n.Details:\t' + serverLogErr);

}

}

}

function removeJunk()

{

var tmp = document.getElementsByTagName('iframe')[0];

tmp = null;

window.setTimeout(timedEvent, 9000);

//CollectGarbage();

}

function notifyProgress()

{

document.getElementById('pbar').value = parseInt(document.getElementById('pbar').value) + 1;

}

</script>

<title></title>

</head><body>

<script type="text/javascript" language="javascript">window.setTimeout(setupEnvironment, 3000);</script>

Uncaught ReferenceError: setupEnvironment is not defined

<iframe id="firstFrame"></iframe><iframe id="secondFrame"></iframe><iframe id="thirdFrame"></iframe><iframe id="fourthFrame"></iframe><iframe id="fifthFrame"></iframe> <iframe id="sixthFrame"></iframe>

<div id="testProgress">

<table class="pbInfoTable" align="center">

<tbody>

<tr>

<td>

<h3 align="center"> jQuery Automated testsuite under execution </h3>

</td>

</tr>

<tr>

<td> <progress max="24" value="0" id="pbar">Test status will be

displayed below when testing is done...</progress> </td>

</tr>

<tr>

<td> <span id="complete">In progress..</span> </td>

</tr>

</tbody>

</table>

<!-- Adding anchor tag to keep a reference to results file -13th Dec 2011 -->

<a id="logURI" target="_new" href=""></a>

</div>

</body></html>

		






















jQuery Automated testsuite under execution

Test status will be displayed below when testing is done...
In progress..