Getting a full page screenshot?

10 posts, 0 answers
  1. Nick
    Nick avatar
    2 posts
    Member since:
    Nov 2011

    Posted 27 Mar 2012 Link to this post

    My site has a lot of long-form content, so most pages have a scrollbar. Trying to use the Capture method on the browser to get a screenshot works, but only for the visible frame. Is there a way to capture the entire contents of the page to a screenshot?

    I was thinking about doing scrolls, but I can't seem to find a scroll / page height that I can use to calculate how far and how many times I need to scroll so I can stitch together an image. Is it possible to get such information?

    Thanks,
    Nick
  2. Asta
    Asta avatar
    29 posts
    Member since:
    Nov 2011

    Posted 27 Mar 2012 Link to this post

    I don't think you could capture all screen. You can try by capturing just an object from page. If this will do any help
    try
               {
                   System.Drawing.Bitmap image = ActiveBrowser.Capture();
                   if (image != null)
                   {
                       var fileName = TypeName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff");
                       string testFilePath = System.IO.Path.Combine(Logger.TestRunScreenshotFilesFolder, fileName);
                       fileName = Path.ChangeExtension(testFilePath, ".png");
                       image.Save(fileName, ImageFormat.Png);
                       Logger.Error(String.Format("System wasn't working as expected. You can see screenshot of it here '{0}'", testFilePath));
                   }
               }
               catch (Exception)
               { }
  3. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 30 Mar 2012 Link to this post

    Hello Nick,

    Yes, you can capture the entire window or a targeted portion of that window using the Window.GetBitmap() method. Please follow this article for more information. Unfortunately we can only capture what is currently visible. We do not have a method in which you can capture the entire contents of the web page, scrolling along the way.

    Greetings,
    Ivaylo
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Rizwan
    Rizwan avatar
    1 posts
    Member since:
    May 2013

    Posted 10 May 2013 Link to this post

    can u pls tell me how you took the screen shot of client machine (browser) in session enabled website...
    Thanks in advance..
  5. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 14 May 2013 Link to this post

    Hello Rizwan,

    You can capture an image of the browser at any point in the test and save that image to the hard drive. Here's how it looks in code:

    System.Drawing.Bitmap image = ActiveBrowser.Capture();
    image.Save("C:\\MySavedImages\\CurrentBrowser.png", System.Drawing.Imaging.ImageFormat.Png);

    Some other ways of capturing the browser state are listed in the replies above as we as this article

    Kind regards,
    Ivaylo
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  6. Nabil
    Nabil avatar
    1 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 Link to this post

    Any update on this please? 
    I got the same issue by cant go over it 
  7. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 02 Apr 2014 Link to this post

    Hello Nabil,

    Please be more specific on what exactly you are experiencing. This thread was updated last year and it seems the last response solved the problem. 
    Please refer to the code provided in the previous post and give it a try, it is quite straight forward and it should work without any issues.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  8. Rosa
    Rosa avatar
    1 posts
    Member since:
    Aug 2014

    Posted 11 Aug 2014 Link to this post

    Hello, Nick. Why not try some screenshot tools like screenshot extensions? There are tons of these extensions, such as Awesome Screenshot, Fireshot, Nimbus Screenshot and so on. If you don't want to install any plug-ins, you can make use of some online screenshot applications like Webpage Screenshot Capture
  9. MK Siva
    MK Siva avatar
    1 posts
    Member since:
    Jan 2016

    Posted 01 Oct Link to this post

    Hi

    I'm getting following error if i use the above give code for screenshots in telerik, Can anyone please help me

    System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format)

    when i googled about this error, it says the issue is with  the folder access , but i checked there are no access issues with the directory,

    Thanks,

    KM

  10. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 05 Oct Link to this post

    Hi,

    This code works correctly on my side and it capture an image without issues. See that video.

    Could you please try changing the folder or run Test Studio as Administrator?

    Hope to hear from you soon.

    Regards,
    Boyan Boev
    Telerik by Progress
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top