Forum Discussion

DonN's avatar
DonN
Occasional Contributor
8 years ago

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