0

I am trying to use webdriver to save away an image of what would currently be in the dom, where some of the items may be 1500px+ in height. And so taking a screenshot of this doesn't help as at best I can get 1080. As when in testing it may well be lower.

I have tried researching and finding ways of doing this for most of the day, And thought I had Found something that would do the trick

var element = FindElement(By.ClassName("contentBody"));
int width = element.Size.Width;
int height = element.Size.Height;
Point point = element.Location;
int x = point.X; 
int y = point.Y;
RectangleF part = new RectangleF(x, y, width, height);
Bitmap bmpobj = new Bitmap((int)part.Width, (int)part.Height);
Bitmap bn = bmpobj.Clone(part, bmpobj.PixelFormat);
bn.Save(path, ImageFormat.Png);

However I am getting an outofmemory exception when cloning the rectangle across. in this particular example the element is a div where the bounds are 1220 x 3045 (It is essentially a list of items) and I would like to save this away for comparisons later.

If anyone has any idea how to solve this your help would be greatly appreciated.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Steven Dall
  • 174
  • 2
  • 15
  • why a screenshot? if it's a list of items, i'd just read the text of the options and save that as text somewhere – ddavison Mar 24 '14 at 12:11
  • the items are fairly indepth objects that are displayed, just so happens they are in a list like fashion, We are also wanting a screenshot so that we can mail out to the QA department the picture and from there we can make sure that things like layout and alike are also correct. – Steven Dall Mar 24 '14 at 12:25
  • You may want to look at this stack overflow answer here:[Selenium WebDriver C# Full Website Screenshots With ChromeDriver and FirefoxDriver](https://stackoverflow.com/questions/16795458/selenium-webdriver-c-sharp-full-website-screenshots-with-chromedriver-and-firefo) – Michiel Bugher Jun 02 '17 at 17:48

0 Answers0