cancel
Showing results for 
Search instead for 
Did you mean: 

Try this! How to video your tests...

DonN
Occasional Contributor

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();
}
}

 

3 REPLIES 3
DonN
Occasional Contributor

Try this! How to video your tests... The sequel.

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:

 

 

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);
}

 

shankar_r
Community Hero

Re: Try this! How to video your tests... The sequel.

This looks good, but it will take some good memory to store the results.

 

We are using HTML reports to capture the failures as well as the test case flow.

 

You can see that here https://community.smartbear.com/t5/TestComplete-General-Discussions/Automation-Execution-Report-Read...

 

https://community.smartbear.com/t5/TestComplete-General-Discussions/Automation-Execution-Report/m-p/...


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

AlexKaras
Community Hero

Re: Try this! How to video your tests... The sequel.

One more option: https://community.smartbear.com/t5/TestComplete-Functional-Web/When-is-video-recording-being-support...

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements