Contributions
Function to Read the text file and compare with the Baseline
This function will help to read the text file and compare it with Baseline text string. Use Case would be like it will help to read the Logs or any Text File and than compare with the Baseline or any expected Text output in the file. //function is to find Text in the Text File and compare with the Baseline function CompareTextLine(filePath,stringid, baseline) { var read, line, result, nores; //open and read text file read = aqFile.OpenTextFile(filePath, aqFile.faRead, aqFile.ctANSI); //set the ANSI UTF or any other format of Text File read.Cursor = 0; nores = 0; //Searching each line for the identifying key string while(! read.IsEndOfFile()) { line = read.ReadLine(); result = aqString.Find(line, stringid); if (result != -1) // -1 indicates occurrence not found { Log.Message("The key string identifier was found in this line = " + line + "; the baseline to compare = " + baseline); if (baseline == line) { Log.Checkpoint("The string found matches the baseline"); return; } else { Log.Warning("The value is not correct. Actual = " + line + "; Expected = " + baseline);} nores = 1; } } read.Close(); //Log error if string was not found if (nores == 0) Log.Error("String was not found in any of the text lines."); }607Views2likes0CommentsFunction to wait for processing to complete
In many cases we have seen that processing times varies so it will wait for the processing to get idle and you can edit the max timeout in this , so this will help in cases of rendering and some process extensive work where we cant use any wait command or any other progress. I tried this most of the CAD Softwares like AutoCAD, SolidWorks, Navisworks, Revit, Aveva PDMS, Bentley Microstation, BricsCAD and it worked well. //function is to Wait for CPU processing to get Idle and with a timeout time function WaitForProcessing() { Log.Message("Memory Usage : " + Sys.Process("PROCESS").MemUsage); var time1 = aqDateTime.Time(); while(Sys.Process("PROCESS").CPUUsage != 0) { Log.CheckPoint("While Loop : cpu usage " + Sys.Process("PROCESS").CPUUsage); aqUtils.Delay(2000,"Wait for Processing"); //Waiting for 2 sec //Timeout for max 10sec var time2 = aqDateTime.Time(); var diff = time2 - time1; if(diff >= 10000) ///Please edit the time accordingly { Log.CheckPoint("Max Timeout for While loop with time : " + diff); break; } } Log.Message("While Loop Completed with Cpu Usage : " + Sys.Process("PROCESS").CPUUsage); }655Views3likes0CommentsRe: Desktop application Launch
1. you can use Variables also and define the local value based on the system but this needs to be done all the time, useful if the size of the file is too big. 2. you can add in the Project folder and use the path as Marsha mentioned. 3. You can also use Stores- Files in this you can use it for verification also and will be automatically in sync with the Version Control if used any. https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/stores/files/index.html742Views0likes0CommentsRe: How To open a testedapp file(Test Document) from a path
Option 1. Automate the step to click on New and File Option 2. Use Command Line para available for Window Word :winword.exe <filepath> you can set it from the code as shown below TestedApps.notepad.Params.ActiveParams.CommandLineParameters ="\"" +"C:\\My File.txt"+ "\""; TestedApps.notepad.Run(); Link: https://support.smartbear.com/testcomplete/docs/testing-with/tested-apps/desktop/command-line.html Please consider giving a Kudo if I write good stuff690Views1like1CommentRe: Unexpected behaviou handling
1. For any unexpected window - you can use the Events of Unexpected window and write the respective cleaning function in it. 2. Runner.Stop(true) : you can make use of this function whenever you feel your settings are matching with the expected and wanted to stop the testcase there.746Views1like1Comment