ContributionsMost RecentMost LikesSolutionsRe: Reading PDF documents Read pdf to verify a report in test complete. You have to import pdfbox.dll Read report pdf data and validate any string to verify a test functionality. function verifyPDFTextValue(){ var status = verifyPDFText("50 plus_ element"); return status; } function readPDFData(strReportFilePath) { var filePath = callPDF(); var doc = dotNET.org_apache_pdfbox_pdmodel.PDDocument.load(filePath); var pdfStripper = dotNET.org_apache_pdfbox_util.PDFTextStripper.zctor_2(); var str = pdfStripper.getText_2(doc); Log.Message("See Additional Info", str); doc["close"](); return str; } function verifyPDFText( strTextToVerify ){ var status ; var pdfFileFullPath = callPDF(); var pdfText = readPDFData(pdfFileFullPath); if(pdfText.Contains(strTextToVerify)){ Log["Message"]("Verification successful. Text in PDF file is equal!"); status = "Success"; } else { Log["Error"]("Text in PDF file is different from the parameter passed!"); status = "Failure"; } return status; } // We should call last modified file in place of below method in a dynamic environment. function callPDF(){ var sPath = "../IrisProject/TestData/TestDataPDF/TestPDF.pdf" var sExpPath = aqFileSystem["ExpandFileName"](sPath); var fileName = aqFileSystem["GetFileNameWithoutExtension"](sExpPath); // Posts the file name and extension to the test log Log["Message"]("The file name is " + fileName); Files["TestPDF"]["Check"](fileName); Log.Message(sExpPath); return sExpPath; } For any means the report or pdf file path/name is dynamic then below method will help to get the latest file in a folder. pass that path to readPDFData function insted of calling function callPDF(). function getLastModifiedFileName(){ var status ; Delay(5000); var reportsPath = CreateReportFolder(); Delay(5000); var fileToSearch = FindLastModifiedFileInFolder(reportsPath, ".*"); Log["Message"](fileToSearch); if(fileToSearch != null) { Log["Message"]("File found " + fileToSearch); status = "Success"; } else { Log["Error"]("File not found!"); status = "Failure"; } return status; } //This method Creates report folder under project root folder, if report folder does not exists , ignores otherwise. function CreateReportFolder() { var reportsFolderRelativePath = "../IrisProject/PTPReports"; var reportsFolderFullPath = aqFileSystem["ExpandFileName"](reportsFolderRelativePath); if(!aqFileSystem["Exists"](reportsFolderFullPath)) { reportsFolderFullPath = aqFileSystem["CreateFolder"](reportsFolderFullPath); } return reportsFolderFullPath; } function FindLastModifiedFileInFolder(FolderPath,FileNameContains) { var FolderObject = aqFileSystem.GetFolderInfo(FolderPath); //The folder to look in var FileItems = FolderObject.Files //Collection of all the files in the folder var FileDateModified = new Array(); //Array of all the relevant date modified info for the files var FileNumber = new Array(); //The absolute index number for the files sorted var LatestFileNumber; //The index to the latest file modified var NewestTime; //Placeholder for the Newest time when searching //Builds up the arrays with the filnames containing FileNameContains reg exp for (var i=0; i < FileItems.Count; i++) { if(FileItems.Item(i).Name.search(FileNameContains) > -1) { FileNumber.push(i); FileDateModified.push(FileItems.Item(i).DateLastModified); } } //Finds the most resent modified file NewestTime = FileDateModified[0]; Log["Message"](NewestTime); LatestFileNumber = FileNumber[0]; Log["Message"](FileDateModified); for (var i=0; i < FileNumber.length; i++) { if(aqDateTime["Compare"](NewestTime, FileDateModified[i]) < 0) { NewestTime = FileDateModified; LatestFileNumber = FileNumber; } } return FileItems.Item(LatestFileNumber).Path; } Find the screenshot it will help in getting a clear idea. ***** For any further queries...............reply back:) Re: Read and write to excel file Since DTD driver won't write back to excel. First we need to read the excel and count all the rows as in below function. I have implemented using C#Script but the concept is same. It can be with other scripting languages too. //Function to read excel file row by row. function getExcelRowCount(varAny1 , varAny2){ //varAny1 , varAny2 are excel file path and excel sheet name respectively. var count = 0; Delay(3000); driver = DDT["ExcelDriver"](varAny1, varAny2, true); var isEndOFFile = driver["EOF"](); while (!driver["EOF"]()) { if((driver["Value"]("TestExecutionFlag") == "Y") || (driver["Value"]("TestExecutionFlag") == "y")) { count ++; } else if((driver["Value"]("TestExecutionFlag") == "N") || (driver["Value"]("TestExecutionFlag") == "n")) { count ++; } driver["Next"](); } DDT["CloseDriver"](driver["Name"] ); Log["Message"](count); return count; } Once we have all the row count with us. We can iterate through it and execute all the test methods like below. //Since DTD driver won’t write back the test status to excel file, we have to do a work around. Below method will get the status message from test method and write to excel; whether the test is paa or fail. // We only have to return success or failure from test methods. // COMMON_CONSTANTS["testStatusColumnValue"] is an integer value for column number to be updated with test result(Pass, Fail or Not Run). For reusability purpose i am calling it from Constant(Property) file. function executeTestCaseFromExcelFile(fname, sheetName) { count = getRowCount(fname, sheetName); var passString = "Pass"; var failString = "Fail"; var notRunString = "Not Run"; var statusColumn = 5; var app = Sys.OleObject("Excel.Application"); var book = app.Workbooks.Open(fname); var sheet = book.Sheets(sheetName); app.DisplayAlerts = false; Delay(3000); for(var row = 2; row <= count + 1; row++) { if((sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"] -1) == "Y") || (sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"] -1) == "y")) { var testMethodName = sheet.Cells(row, 3).Value; var runnerResult = Runner["CallMethod"](testMethodName); var isSuccess = aqString["Compare"](runnerResult, "Success", false); Log["Message"]("status runnerResult type is = " + isSuccess); var errCnt = Log["ErrCount"]; Log["Message"]("errCnt = " + errCnt); if(isSuccess == 0) { sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"]).Interior.ColorIndex = 4; //4 is color index of Green sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"]) = passString; } else { sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"]).Interior.ColorIndex = 3; //3 is color index of Red sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"]) = failString; } } else if((sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"] -1) == "N") || (sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"] -1) == "n")) { sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"]).Interior.ColorIndex = 6; //6 is color index of Yellow sheet.Cells(row, COMMON_CONSTANTS["testStatusColumnValue"]) = notRunString; } } book.Save(); app.Quit(); } Consider below as an example of test method and implement accordingly. function LaunchAndCloseApplication(){ var result; TestedApps["calc"]["Run"](1, false, 30000) var lnkCalc = Aliases["XYZ"]; Delay(10000); if(lnkCalc ["Exists"] == true){ result = "Success"; } else { result = "Failure"; } lnkCalc ["Click"](); return result; } TC ID TestDescription TestMethodName TestExecutionFlag Result 1 Verify that the application is launched successfully. LaunchAndCloseApplication.LaunchAndCloseApplication Y Fail 2 Verify PDF data. ReadPDFData.verifyPDFTextValue N Not Run 3 Verify the path of last modified file in a folder. LastModifiedFileInFolder.getLastModifiedFileName Y Pass Hope this helps. For further query , reply back.