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
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)
{ }
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.
Ivaylo
the Telerik team
Test Studio Trainings
Thanks in advance..
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
Test Studio Trainings
I got the same issue by cant go over it
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
Test Studio Trainings
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
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
Test Studio Trainings