0

Does someone knows a way to create full page screenshots using WebDriver?

I want if one of my tests fails to create a FULL PAGE (even the not visible part on the screen) screenshot before the browser close and save it on share location.

Also, if it is possible I want to output the result to Jenkins Console log.

Thanks!

GanchoG
  • 13
  • 6
  • possible duplicate of [Take a screenshot with Selenium WebDriver](http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver) – ekuusela May 07 '15 at 19:38
  • Also possible duplicate of http://stackoverflow.com/questions/29816688/take-a-page-shoot-with-selenium-web-driver – JimEvans May 07 '15 at 22:03

2 Answers2

0

You can use the following extension for Firefox: https://addons.mozilla.org/nl/firefox/addon/fireshot/

You can find its javascript code in %APPDATA%\Mozilla\Firefox\Profiles\

The extensions provide the ability to copy the screenshot to the clipboard. You can use its JS methods to perform the screenshot. After that, you can retrieve the image from the clipboard and save it to as a file on shared location.

    Image image = default(Image);
    if (Clipboard.GetDataObject() != null)
    {
        IDataObject data = Clipboard.GetDataObject();

        if (data.GetDataPresent(DataFormats.Bitmap))
        {
            Image image = (Image)data.GetData(DataFormats.Bitmap,true);

            image.Save("image.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
        }
        else
        {
            Console.WriteLine("The Data In Clipboard is not as image format");
        }
    }
    else
    {
        Console.WriteLine("The Clipboard was empty");
    }
   string newImageName = string.Concat(@"C:\SampleSharedFolder\", Guid.NewGuid());
   image.Save(newImageName );    
   Console.WriteLine("Image save location: {0}", newImageName);

Once you have populated the result to Console it is really easy to output it back to Jenkins. You can find more in my article: http://automatetheplanet.com/output-mstest-tests-logs-jenkins-console-log/

Anton Angelov
  • 1,705
  • 13
  • 16
0

You can use Snagit to perform full page screenshots. More information here: https://www.techsmith.com/tutorial-snagit-documentation.html

First you need to start the Snagit server and then follow the documentation.

Chervenkov
  • 63
  • 1
  • 1
  • 6