This repository has been archived by the owner on Nov 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
api.min.js
1 lines (1 loc) · 14 KB
/
api.min.js
1
function ExportCSV(e){var t="data:text/csv;charset=utf-8,";e.forEach(function(e,r){dataString=e.join(";"),t+=dataString+"\n"});var r=encodeURI(t);window.open(r)}var CurrentFlowMode,CurrentLevelOneTitle,CurrentLevelOneID,CurrentLevelOneLength,CurrentLevelTwoTitle,CurrentLevelTwoID,CurrentLevelTwoLength,CurrentLevelThreeTitle,CurrentLevelThreeID,CurrentLevelThreeLength,TestScriptData,CurrentLevelOne=0,CurrentLevelTwo=0,CurrentLevelThree=0;function FetchFlowData(){PrintToConsole("FetchData",(CurrentFlowMode=TestScriptData.UseCaseAutoFlow)?"Use Case flow is auto.":"Use Case flow is manual.")}function FetchLevelOneData(){CurrentLevelOneTitle=TestScriptData.UseCases[CurrentLevelOne].UseCaseTitle,CurrentLevelOneID=TestScriptData.UseCases[CurrentLevelOne].UseCaseID,CurrentLevelOneLength=TestScriptData.UseCases.length}function FetchLevelTwoData(){CurrentLevelTwoTitle=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionTitle,CurrentLevelTwoID=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionID,CurrentLevelTwoLength=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions.length}function FetchLevelThreeData(){CurrentLevelThreeTitle=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionSteps[CurrentLevelThree].ActionStepTitle,CurrentLevelThreeID=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionSteps[CurrentLevelThree].ActionStepID,CurrentLevelThreeLength=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionSteps.length}function LoadData(e){LoadJSON(e+"UseCaseData.json","Use case data loaded successfully.",function(e){TestScriptData=JSON.parse(e)})}function LoadJSON(e,r,t){var n=new XMLHttpRequest;n.overrideMimeType("application/json"),n.open("GET",e,!0),n.onload=function(){4==n.readyState&&"200"==n.status?(t(n.responseText),PrintToConsole("LoadJSON",r),FetchFlowData()):PrintToConsole("LoadJSON","Data could not be loaded.")},n.send(null)}function Init(e){PrintInitialLogs(),LoadData(e)}function UxBeginUseCase(e,r){FetchLevelOneData();var t='User interacted with element "'+r+'". ';return!1!==LevelOneRunning?(AddToPrintStack(LevelTwoRunning?LevelThreeRunning?13:8:3,t,r),!0):!1===LevelTwoRunning&&!1===LevelThreeRunning?(CurrentLevelOne==e?(LevelOneCounter=parseInt(CurrentLevelOne)+1,t+='Begin of use case "'+CurrentLevelOneTitle+'" ['+CurrentLevelOneID+"], ",AddToPrintStack(1,t+="use case "+LevelOneCounter+" out of "+CurrentLevelOneLength+".",r),LevelOneRunning=!0,!(CurrentLevelTwo=0)===CurrentFlowMode&&UxBeginAction(e,0,r)):AddToPrintStack(0,t,r),!0):void 0}function UxCompleteUseCase(e,r){FetchLevelOneData();var t='User interacted with element "'+r+'". ';return LevelOneRunning?!1!==LevelTwoRunning?(AddToPrintStack(LevelThreeRunning?13:8,t,r),!0):!1===LevelThreeRunning?(CurrentLevelOne===e&&CurrentLevelTwo===CurrentLevelTwoLength?(t+='Completion of use case "'+CurrentLevelOneTitle+'" ['+CurrentLevelOneID+"], ",AddToPrintStack(4,t+="use case "+LevelOneCounter+" out of "+CurrentLevelOneLength+".",r),LevelOneRunning=!1,CurrentLevelOne++,CurrentFlowMode&&CurrentLevelOne<CurrentLevelOneLength?UxBeginUseCase(e+1,r):CurrentLevelOne==CurrentLevelOneLength&&UxCompleteSession()):AddToPrintStack(3,t,r),!0):void 0:(AddToPrintStack(2,t,r),!0)}function UxBeginStep(e,r,t,n){FetchLevelThreeData();var s='User interacted with element "'+n+'". ';return LevelOneRunning?LevelTwoRunning?!1===LevelThreeRunning?CurrentLevelOne==e&&CurrentLevelTwo==r&&CurrentLevelThree==t?(LevelThreeCounter=parseInt(CurrentLevelThree)+1,s+='Begin of step "'+CurrentLevelThreeTitle+'" ['+CurrentLevelThreeID+"], ",AddToPrintStack(11,s+="step "+LevelThreeCounter+" out of "+CurrentLevelThreeLength+".",n),LevelThreeRunning=!0):(AddToPrintStack(10,s,n),!0):LevelThreeRunning?(AddToPrintStack(13,s,n),!0):void 0:(AddToPrintStack(7,s,n),!0):(AddToPrintStack(2,s,n),!0)}function UxCompleteStep(e,r,t,n){FetchLevelThreeData();var s='User interacted with element "'+n+'". ';return LevelOneRunning?LevelTwoRunning?LevelThreeRunning?CurrentLevelOne==e&&CurrentLevelTwo==r&&CurrentLevelThree==t?(s+='Completion of "'+CurrentLevelThreeTitle+'" ['+CurrentLevelThreeID+"], ",AddToPrintStack(14,s+="step "+LevelThreeCounter+" out of "+CurrentLevelThreeLength+".",n),CurrentLevelThree++,!(LevelThreeRunning=!1)===CurrentFlowMode&&(CurrentLevelThree<CurrentLevelThreeLength?UxBeginStep(e,r,t+1,n):CurrentLevelThree===CurrentLevelThreeLength&&UxCompleteAction(e,r,n))):AddToPrintStack(13,s,n):AddToPrintStack(12,s,n):AddToPrintStack(7,s,n):AddToPrintStack(2,s,n),!0}function UxBeginAction(e,r,t){FetchLevelTwoData();var n='User interacted with element "'+t+'". ';return LevelOneRunning?!1!==LevelTwoRunning?(AddToPrintStack(LevelThreeRunning?13:8,n,t),!0):!1===LevelThreeRunning?(CurrentLevelOne==e&&CurrentLevelTwo===r?(LevelTwoCounter=parseInt(CurrentLevelTwo)+1,n+='Begin of action "'+CurrentLevelTwoTitle+'" ['+CurrentLevelTwoID+"], ",AddToPrintStack(6,n+="action "+LevelTwoCounter+" out of "+CurrentLevelTwoLength+".",t),LevelTwoRunning=!0,!(CurrentLevelThree=0)===CurrentFlowMode&&UxBeginStep(e,r,0,t)):AddToPrintStack(5,n,t),!0):void 0:(AddToPrintStack(2,n,t),!0)}function UxCompleteAction(e,r,t){FetchLevelTwoData();var n='User interacted with element "'+t+'". ';return LevelOneRunning?LevelTwoRunning?!1===LevelThreeRunning?CurrentLevelOne==e&&CurrentLevelTwo==r&&CurrentLevelThree==CurrentLevelThreeLength?(n+='Completion of action "'+CurrentLevelTwoTitle+'" ['+CurrentLevelTwoID+"], ",AddToPrintStack(9,n+="action "+LevelTwoCounter+" out of "+CurrentLevelTwoLength+".",t),LevelTwoRunning=!1,CurrentLevelTwo++,CurrentFlowMode&&(CurrentLevelTwo<CurrentLevelTwoLength?UxBeginAction(e,r+1,t):CurrentLevelTwo===CurrentLevelTwoLength&&UxCompleteUseCase(e,t))):AddToPrintStack(8,n,t):AddToPrintStack(13,n,t):AddToPrintStack(7,n,t):AddToPrintStack(2,n,t),!0}var LevelOneCounter,LevelTwoCounter,LevelThreeCounter,LevelOneRunning=!1,LevelTwoRunning=!1,LevelThreeRunning=!1;function UxSetInteraction(e){var r='User interacted with the "'+e+'" element.';AddToPrintStack(LevelTwoRunning&&LevelThreeRunning?15:16,r,e)}function UxCompleteSession(){ExportCSV(TestResultsArray)}var LogsData=[{logid:"0",message:"Wrong use case!"},{logid:"1",message:"Use case started!"},{logid:"2",message:"Use case not yet started!"},{logid:"3",message:"Current use case not yet completed!"},{logid:"4",message:"Use case completed!"},{logid:"5",message:"Wrong action!"},{logid:"6",message:"Action started!"},{logid:"7",message:"Action not yet started!"},{logid:"8",message:"Current action not yet completed!"},{logid:"9",message:"Action completed!"},{logid:"10",message:"Wrong step!"},{logid:"11",message:"Step started!"},{logid:"12",message:"Step not yet started!"},{logid:"13",message:"Current step not yet completed!"},{logid:"14",message:"Step completed!"},{logid:"15",message:"Interaction triggered while step is pending."},{logid:"16",message:"Interaction triggered while step has been completed."}],BrowserLogHeadersCounter=0,BrowserLogsCounter=1;function PrintBrowserLogs(){PrintBrowserLogsToConsole(),PrintBrowserLogHeaders(),PrintBrowserLogResults()}function PrintBrowserLogsToConsole(){navigator.cookieEnabled?PrintToConsole("GetNavigator","Browser cookies are enabled."):PrintToConsole("GetNavigator","Browser cookies are disabled."),PrintToConsole("GetNavigator","Browser Code Name: "+navigator.appCodeName),PrintToConsole("GetNavigator","Browser Name: "+navigator.appName),PrintToConsole("GetNavigator","Browser Version: "+navigator.appVersion.replace(/;/g," @")),PrintToConsole("GetNavigator","Browser Language: "+navigator.language),PrintToConsole("GetNavigator","Browser Platform: "+navigator.platform),PrintToConsole("GetNavigator","Browser Engine: "+navigator.product),PrintToConsole("GetNavigator","Browser Agent: "+navigator.userAgent.replace(/;/g," @")),navigator.javaEnabled()?PrintToConsole("GetNavigator","Java is enabled."):PrintToConsole("GetNavigator","Java is disabled.")}function PrintBrowserLogHeaders(){TestResultsArray[BrowserLogHeadersCounter]=[],TestResultsArray[BrowserLogHeadersCounter][0]="Browser Details",TestResultsArray[BrowserLogHeadersCounter][1]="Browser Cookies",TestResultsArray[BrowserLogHeadersCounter][2]="Browser Code Name",TestResultsArray[BrowserLogHeadersCounter][3]="Browser Name",TestResultsArray[BrowserLogHeadersCounter][4]="Browser Version",TestResultsArray[BrowserLogHeadersCounter][5]="Browser Language",TestResultsArray[BrowserLogHeadersCounter][6]="Browser Platform",TestResultsArray[BrowserLogHeadersCounter][7]="Browser Engine",TestResultsArray[BrowserLogHeadersCounter][8]="Browser Agent",TestResultsArray[BrowserLogHeadersCounter][9]="Java enabled"}function PrintBrowserLogResults(){TestResultsArray[BrowserLogsCounter]=[],TestResultsArray[BrowserLogsCounter][0]="",TestResultsArray[BrowserLogsCounter][1]=navigator.cookieEnabled,TestResultsArray[BrowserLogsCounter][2]=navigator.appCodeName,TestResultsArray[BrowserLogsCounter][3]=navigator.appName,TestResultsArray[BrowserLogsCounter][4]=navigator.appVersion.replace(/;/g," @"),TestResultsArray[BrowserLogsCounter][5]=navigator.language,TestResultsArray[BrowserLogsCounter][6]=navigator.platform,TestResultsArray[BrowserLogsCounter][7]=navigator.product,TestResultsArray[BrowserLogsCounter][8]=navigator.userAgent.replace(/;/g," @"),TestResultsArray[BrowserLogsCounter][9]=navigator.javaEnabled()}var TestResultsArray=[],LogConsoleCounter=0;function PrintInitialLogs(){PrintBrowserLogs(),PrintScreenLogs(),PrintUseCaseLogHeaders()}function AddToPrintStack(e,r,t){PrintResults(LogsData[e].message,r,t),BrowserConsole("["+LogConsoleCounter+"] "+LogsData[e].message+"\n"+r),LogConsoleCounter++}function PrintToConsole(e,r){BrowserConsole(LogConsoleCounter<10?"[0"+LogConsoleCounter+"] > ["+e+"] "+r:"["+LogConsoleCounter+"] > ["+e+"] "+r),LogConsoleCounter++}function BrowserConsole(e){console.log(e)}var ScreenLogHeadersCounter=2,ScreenLogsCounter=3;function PrintScreenLogs(){PrintScreenLogsToConsole(),PrintScreenLogHeaders(),PrintScreenLogResults()}function PrintScreenLogsToConsole(){PrintToConsole("GetResolution","Screen height: "+window.screen.height),PrintToConsole("GetResolution","Screen width: "+window.screen.width),PrintToConsole("GetResolution","Window available height: "+window.screen.availHeight),PrintToConsole("GetResolution","Window available width: "+window.screen.availWidth),PrintToConsole("GetResolution","Window height: "+window.innerHeight),PrintToConsole("GetResolution","Window width: "+window.innerWidth)}function PrintScreenLogHeaders(){TestResultsArray[ScreenLogHeadersCounter]=[],TestResultsArray[ScreenLogHeadersCounter][0]="Screen details",TestResultsArray[ScreenLogHeadersCounter][1]="Screen height",TestResultsArray[ScreenLogHeadersCounter][2]="Screen width",TestResultsArray[ScreenLogHeadersCounter][3]="Window available height",TestResultsArray[ScreenLogHeadersCounter][4]="Window available width",TestResultsArray[ScreenLogHeadersCounter][5]="Window height",TestResultsArray[ScreenLogHeadersCounter][6]="Window width"}function PrintScreenLogResults(){TestResultsArray[ScreenLogsCounter]=[],TestResultsArray[ScreenLogsCounter][0]="",TestResultsArray[ScreenLogsCounter][1]=window.screen.height,TestResultsArray[ScreenLogsCounter][2]=window.screen.width,TestResultsArray[ScreenLogsCounter][3]=window.screen.availHeight,TestResultsArray[ScreenLogsCounter][4]=window.screen.availWidth,TestResultsArray[ScreenLogsCounter][5]=window.innerHeight,TestResultsArray[ScreenLogsCounter][6]=window.innerWidth}var UseCaseLogHeadersCounter=4,UseCaseLogsCounter=5;function PrintUseCaseLogHeaders(){TestResultsArray[UseCaseLogHeadersCounter]=[],TestResultsArray[UseCaseLogHeadersCounter][0]="Counter",TestResultsArray[UseCaseLogHeadersCounter][1]="Date",TestResultsArray[UseCaseLogHeadersCounter][2]="Timestamp",TestResultsArray[UseCaseLogHeadersCounter][3]="Timeframe per interaction",TestResultsArray[UseCaseLogHeadersCounter][4]="Trigger Element",TestResultsArray[UseCaseLogHeadersCounter][5]="UseCase no.",TestResultsArray[UseCaseLogHeadersCounter][6]="UseCase title",TestResultsArray[UseCaseLogHeadersCounter][7]="Action no.",TestResultsArray[UseCaseLogHeadersCounter][8]="Action title",TestResultsArray[UseCaseLogHeadersCounter][9]="Step no.",TestResultsArray[UseCaseLogHeadersCounter][10]="Step title",TestResultsArray[UseCaseLogHeadersCounter][11]="Short message",TestResultsArray[UseCaseLogHeadersCounter][12]="Long message"}function PrintResults(e,r,t){var n=Math.floor(Date.now()/1e3);TestResultsArray[UseCaseLogsCounter]=[],TestResultsArray[UseCaseLogsCounter][0]=UseCaseLogsCounter,TestResultsArray[UseCaseLogsCounter][1]=ConvertTime(n),TestResultsArray[UseCaseLogsCounter][2]=n,TestResultsArray[UseCaseLogsCounter][3]=TestResultsArray[UseCaseLogsCounter][2]-TestResultsArray[UseCaseLogsCounter-1][2],TestResultsArray[UseCaseLogsCounter][4]=t,LevelOneRunning?(TestResultsArray[UseCaseLogsCounter][5]=TestScriptData.UseCases[CurrentLevelOne].UseCaseID,TestResultsArray[UseCaseLogsCounter][6]=TestScriptData.UseCases[CurrentLevelOne].UseCaseTitle):(TestResultsArray[UseCaseLogsCounter][5]="",TestResultsArray[UseCaseLogsCounter][6]=""),LevelTwoRunning?(TestResultsArray[UseCaseLogsCounter][7]=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionID,TestResultsArray[UseCaseLogsCounter][8]=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionTitle):(TestResultsArray[UseCaseLogsCounter][7]="",TestResultsArray[UseCaseLogsCounter][8]=""),LevelThreeRunning?(TestResultsArray[UseCaseLogsCounter][9]=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionSteps[CurrentLevelThree].ActionStepID,TestResultsArray[UseCaseLogsCounter][10]=TestScriptData.UseCases[CurrentLevelOne].UseCaseActions[CurrentLevelTwo].ActionSteps[CurrentLevelThree].ActionStepTitle):(TestResultsArray[UseCaseLogsCounter][9]="",TestResultsArray[UseCaseLogsCounter][10]=""),TestResultsArray[UseCaseLogsCounter][11]=e,TestResultsArray[UseCaseLogsCounter][12]=r,UseCaseLogsCounter++}function ConvertTime(e){var r,t=new Date(1e3*e),n=t.getFullYear(),s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],o=t.getDate(),a=t.getHours(),u=t.getMinutes(),l=t.getSeconds();return l<10?r=o+" "+s+" "+n+", "+a+":"+u+":0"+l:10<=l&&(r=o+" "+s+" "+n+", "+a+":"+u+":"+l),r}