Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gist to illustrate modifying the PhantomJS default timeout of zero to a new value
using Sitecore.ContentTesting.Pipelines.GetScreenShotForURL;
namespace MyLibrary.GetScreenShotForURL
{
public class AddTimeoutToScript : GenerateScreenShotProcessor
{
public string Timeout { get; set; }
private const string StandardExit = "phantom.exit();\r\n});";
private string TimeoutExit => "window.setTimeout(function () {\r\n page.render('%outfile%');\r\n phantom.exit();\r\n }, " + Timeout + ");\r\n});";
public override void Process(GetScreenShotForURLArgs args)
{
args.Script = args.Script.Replace(StandardExit, TimeoutExit);
var outputFilePath = Sitecore.ContentTesting.Helpers.PathHelper.MapPath(args.OutputFilename).Replace("\\", "\\\\");
args.Script = args.Script.Replace($"page.render('{outputFilePath}');", "");
args.Script = args.Script.Replace("%outfile%", outputFilePath);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment