This is a migrated thread and some comments may be shown as answers.

Getting a full page screenshot?

9 Answers 308 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 27 Mar 2012, 09:18 AM
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

9 Answers, 1 is accepted

Sort by
0
Asta
Top achievements
Rank 1
answered on 27 Mar 2012, 09:37 AM
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)
           { }
0
Ivaylo
Telerik team
answered on 30 Mar 2012, 03:27 PM
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
0
Rizwan
Top achievements
Rank 1
answered on 10 May 2013, 06:59 AM
can u pls tell me how you took the screen shot of client machine (browser) in session enabled website...
Thanks in advance..
0
Ivaylo
Telerik team
answered on 14 May 2013, 09:59 AM
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
0
Nabil
Top achievements
Rank 1
answered on 28 Mar 2014, 01:30 PM
Any update on this please? 
I got the same issue by cant go over it 
0
Ivaylo
Telerik team
answered on 02 Apr 2014, 10:40 AM
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
 
0
Rosa
Top achievements
Rank 1
answered on 12 Aug 2014, 12:54 AM
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
0
MK Siva
Top achievements
Rank 1
answered on 01 Oct 2016, 07:17 PM

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

0
Boyan Boev
Telerik team
answered on 05 Oct 2016, 11:07 AM
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
 
Tags
General Discussions
Asked by
Nick
Top achievements
Rank 1
Answers by
Asta
Top achievements
Rank 1
Ivaylo
Telerik team
Rizwan
Top achievements
Rank 1
Nabil
Top achievements
Rank 1
Rosa
Top achievements
Rank 1
MK Siva
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or