ContributionsMost RecentMost LikesSolutionsCan Test Execute login a Windows User? When we reboot the machines come up with a logon screen. If we then run Test Execute with automation it all fails because the machine is not logged in. Is it possible for Test Complete to login a machine it's using? Re: Try this! How to video your tests... We found that the videos were not the best solution for describing a failure condition to developers. The files can be quite large and the action goes through very quickly. For this we are now using StepReporter (psr.exe), a "secret" part of Win10. This can create smaller files than Screen2Gif and the developers can go through the screenshots at their own speed. See: https://social.technet.microsoft.com/Forums/windows/en-US/b78253b1-6e38-4563-9efa-4973414e9a75/problems-step-recorder-psrexe-command-line-options?forum=w7itprogeneral So to start recording screenshots we just do this: function StartStepsRecorder() { kill_PSR(); var stepFilePath = Project.Path + "..\\..\\SourceUIAutomation\\ExportedLogs\\StepRecorder\\"; aqFileSystem.CreateFolder(stepFilePath); var stepFileName = stepFilePath + GetTestName() + ".zip"; var commandLine = "psr.exe /start /output " + "\"" + stepFileName + "\"" + " /sc 1 /gui 1 "; WshShell.Run(commandLine, 1, true); } With this line command it will start taking screenshots of every keystroke until it is stopped, then send this to the mht file name you choose. It will keep the last x screenshots as configured. We added it into function GeneralEvents_OnLogError: This stops the recorder if you want to keep the screenshots file: function StopStepsRecorder() { WshShell.Run("psr.exe /stop"); } This stops the recorder if you do not want to keep the screenshots file, say if the TC run completed ok: We added this into GeneralEvents_OnStopTest: function DeleteStepsRecorderFile() { kill_PSR(); Delay(5000); var stepFilePath = Project.Path + "..\\..\\SourceUIAutomation\\ExportedLogs\\StepRecorder\\"; var stepFileName = stepFilePath + GetTestName() + ".zip"; aqFileSystem.DeleteFile(stepFileName) } function kill_PSR() { Result = WshShell.Run("taskkill /f /t /im psr.exe ", 1, true) Delay(3000); Result = WshShell.Run("taskkill /f /t /im psr.exe ", 1, true) Delay(3000); } Try this! How to video your tests... We have been doing a video of some tests. This is really good to show developers what was happening when an exception occurred, or to show management or customers how our testing looks. The code below is using s2g V2.4. Have a look, any questions, let me know. Don PS There's a sequel... function Screen2GifStart() { kill_Screen2Gif(); path = "..\\..\\..\\DevelopmentTools\\3rdParty\\ScreenToGif24.exe"; ScreenToGif24 = "\"" + BASE_DIRECTORY + path + "\""; Log.Message(ScreenToGif24); WshShell.Run(ScreenToGif24); if (NameMapping.Sys.ScreenToGif24.HwndSource_RecorderLightWindow.WaitNamedChild("RecorderLightWindow",60000).Exists) { Delay(1000); RecordPauseButton = findObjectInAnyForm(NameMapping.Sys.ScreenToGif24.HwndSource_RecorderLightWindow,"RecordPauseButton",0); if (RecordPauseButton != null) { RecordPauseButton.Click(31, 18); } else Log.Warning("Could not start Record for Screen2Gif"); } else Log.Warning("Screen2Gif not starting"); } function Screen2GifSaveAndClose () { var s2gSucceeded = false; if (!Screen2GifSave()) Log.Warning("Screen2GifSave failed"); else { if (!Screen2GifSelectSaveFile()) Log.Warning("Screen2GifSelectSaveFile failed"); else { if (!Screen2GifWaitForEncoderToFinish()) Log.Warning("Screen2GifWaitForEncoderToFinish failed") else s2gSucceeded = true; } } kill_Screen2Gif(); return s2gSucceeded; } function Screen2GifSave() { var editor; var hideableTabControl; var textBox; // 4.2.1 Bypass Name Mapping RecorderLightWindow = findObjectInAnyForm(NameMapping.Sys.ScreenToGif24.HwndSource_RecorderLightWindow.RecorderLightWindow,"RecorderLightWindow",0); if (RecorderLightWindow != null) { StopButton = findObjectInAnyForm(RecorderLightWindow,"StopButton",0); StopButton.Click(26, 15); } else { return(false); } return true; } function Screen2GifSelectSaveFile() { Delay(3000); if (NameMapping.Sys.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.Grid.RibbonTabControl.WaitNamedChild("AwaretabitemFile",5000).Exists) NameMapping.Sys.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.Grid.RibbonTabControl.AwaretabitemFile.Click(37,9); Aliases.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.Grid.RibbonTabControl.Grid.SaveButton.Click(31, 18); if (NameMapping.Sys.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.SaveGrid.Grid.WaitNamedChild("CheckboxOverwriteIfAlreadyExists",1000).Exists) { Aliases.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.SaveGrid.Grid.CheckboxOverwriteIfAlreadyExists.ClickButton(cbChecked); } if (Aliases.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.Grid.RibbonTabControl.Grid.WaitNamedChild("SaveButton",5000).Exists) Aliases.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.Grid.RibbonTabControl.Grid.SaveButton.Click(10,10); var textBox = NameMapping.Sys.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.SaveGrid.Grid.OutputFilenameTextBox; textBox.Click(60, 5); //textBox.Drag(74, 10, -92, -12); var testName = ""; if (Project.TestItems.Current != null) testName = Project.TestItems.Current.Name; else testName = getStack(); Log.Message("this test is called: " + testName); textBox.Keys("^a[Del]" + testName); // NameMapping.Sys.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.SaveGrid.FileExistsGrid.TextblockAFileWithTheSameNameAlreadyExists.ClickButton(cbChecked); NameMapping.Sys.ScreenToGif24.HwndSource_EditorWindow.EditorWindow.ApplyButton.Click(76, 9); return(true); } function Screen2GifWaitForEncoderToFinish() { var giveUp = 50; while (Aliases.ScreenToGif24.HwndSource_Encoder.Encoder.EncodingListView.EncoderListViewItem.Status.OleValue != "Completed") { Log.Message(Aliases.ScreenToGif24.HwndSource_Encoder.Encoder.EncodingListView.EncoderListViewItem.Text.OleValue); Log.Message(Aliases.ScreenToGif24.HwndSource_Encoder.Encoder.EncodingListView.EncoderListViewItem.Status.OleValue); Delay(10000); giveUp = giveUp + 1; if (giveUp >= 100) return false; } Log.Message("Completed"); Aliases.ScreenToGif24.HwndSource_Encoder return true; } function CloseScreen2GifEncoder() { Aliases.ScreenToGif24.HwndSource_Encoder.Close(); } function kill_Screen2Gif() { // TC12 WshShell = Sys.OleObject("WScript.Shell"); Result = WshShell.Run("taskkill /f /t /im ScreenToGif24.exe ", 1, true) Result = WshShell.Run("taskkill /f /t /im ScreenToGif24.exe ", 1, true) Result = WshShell.Run("taskkill /f /t /im ScreenToGif24.exe ", 1, true) Result = WshShell.Run("taskkill /f /t /im ScreenToGif24.exe ", 1, true) Result = WshShell.Run("taskkill /f /t /im ScreenToGif24.exe ", 1, true) Result = WshShell.Run("taskkill /f /t /im ScreenToGif24.exe ", 1, true) if (Sys.WaitProcess("ScreenToGif24", 1000).Exists) { Sys.Process("ScreenToGif24").Terminate(); } } Re: Performance Graphs visible elsewhere. FYI: Have written a little program to decode MHT files. This will pull out all the various packed sections and create unpacked (viewable) files instead. This means you can pull out the performance graphs and display the, in Confluence, where management can then relate to the work done. This reads log file SCW.mht and writes to several files in the Temp directory. This post removes leading spaces so apologies for the format. Enjoy :-) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int counter = 0; string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader("c:\\temp\\SCW.mht"); while ((line = file.ReadLine()) != null) { var jpgLoc = line.LastIndexOf(".jpg"); var gifLoc = line.LastIndexOf(".gif"); var pngLoc = line.LastIndexOf(".png"); var bmpLoc = line.LastIndexOf(".bmp"); var htmLoc = line.LastIndexOf(".htm"); var jsLoc = 0; // line.LastIndexOf(".js"); if ((jpgLoc > 0) || (gifLoc > 0) || (pngLoc > 0) || (bmpLoc > 0) || (htmLoc > 0) || (jsLoc > 0)) { var dashLoc = line.LastIndexOf("_"); var revSlashLoc = line.LastIndexOf("\\"); var slashLoc = line.LastIndexOf("/"); if (revSlashLoc > dashLoc) dashLoc = revSlashLoc; if (slashLoc > dashLoc) dashLoc = slashLoc; // var fileName = SST(line); var fileName = line.Substring(dashLoc + 1); if (fileName != null) { Console.WriteLine(fileName); CreateEncodedFile(fileName, file); Zane(fileName); } } counter++; Console.WriteLine(counter); } file.Close(); // Suspend the screen. Console.ReadLine(); } static void CreateEncodedFile(string filename, System.IO.StreamReader file) { int counter = 0; string line; System.IO.StreamWriter outfile = new System.IO.StreamWriter("c:\\temp\\Zipped\\" + filename); line = file.ReadLine(); line = "xxx"; while (line != "") { line = file.ReadLine(); // Console.WriteLine(line); outfile.WriteLine(line); } outfile.Close(); } // outfile /* static string SST(string s) { int found = 0; string zzz = ""; found = s.LastIndexOf("_"); if (found > 0) { //Console.WriteLine("Found = " + found + " len = " + s.Length); zzz = s.Substring(found + 1); //Console.WriteLine(" {0}", zzz); } return zzz; } */ static void Zane(string filename) { string encodedString = System.IO.File.ReadAllText("C:\\Temp\\Zipped\\" + filename); byte[] data = Convert.FromBase64String(encodedString); //string decodedString = Encoding.UTF8.GetString(data); //string[] lines = { data }; System.IO.File.WriteAllBytes("c:\\temp\\unZipped\\" + filename, data); } } } Performance Graphs visible elsewhere. The performance graph is excellent, but can only be seen in Test Complete itself. Please allow this graph to be exported to PDF or something so we can show this excellent graph in places management can see it. Performance Counters We really like the graphs for the Performance Counters. How do we export these graphs to use in, say Atlassian Confluence? Log.SaveResultsAs HTML 2/ Log.SaveResultsAs HTML works some of the time, but not most of the time. It does work if you run a single test. If you keep writing a new version to the HTML each time you finish a test (in the same way as we successfully write to lsMHT below), it gets a consistent error like this: Cannot create file E:\BuildAgent\work\b3356916b7089288\GUIAutomation\SourceUIAutomation\SmokeTests\ExportedLogs\ResultsManager_Stats\RiverOperatorResultsManager\RiverOperatorSmokeTests\General\RiverOperatorCreateNewROProject\ScriptTestLogRO_Create_New_ProjectCreateNewROProject\_TestLog.js 17/09/2016 5:19:58 PM Normal Error Our code looks like this: if (aqString.Find(runName, "Source.mds") != -1) { // Saves the test results var WorkDir = Project.ConfigPath + "..\\ExportedLogs\\"; var FileName = WorkDir + "SmokeTests.mht"; Log.SaveResultsAs(FileName, lsMHT); // Saving as a Web page var testname = arguments.callee.toString().match(/function ([^\(]+)/)[1]; var PName = Project.FileName; Log.Message("PName = " + PName); var Name = Project.TestItems.Current.Name; var Element = Project.TestItems.Current.ElementToBeRun; Log.Message("Name is: " + Name + " and Element is : " + Element); WorkDir = Project.ConfigPath + "ExportedLogs\\"; var FileName = WorkDir + Name; Log.Message("FileName is: " + FileName); Log.Message("Project.ConfigPath is: " + Project.ConfigPath); Log.SaveResultsAs(FileName, lsHTML); //IfHTML This fancy code is to try to get around the errors when the command is asked to simply write to the same filename as the MHT one does. First test creates HTML, second test doesn't. Solved1/ Checking the TC/TE licence server is online. We have several machines running TE on our network. 1/ Checking the TC/TE licence server is online. We have several machines running TE on our network. They reboot after a test and it can happen that they start their next task before they have connected with the TC licence server. Given they run silent, can we either - have the TE run fail with a specific non-zero code, or - run a separate line command that can check the server is responding before the run starts?