3

Following this SO post I was able to take screenshots but they turned out to be just white. I tried couple of workarounds with no avail

  1. Tried using one monitor instead of usual two
  2. Used different image format
  3. Included System.Drawing reference even though I didn't an compiler error.

Code

Screenshot ss=((ITakesScreenshot)driver).GetScreenshot();
ss.SaveAsFile("test.png", System.Drawing.Imaging.ImageFormat.Png);

What should be my next steps. I am using C# 4.0

Community
  • 1
  • 1
satyajit
  • 1,470
  • 3
  • 22
  • 43
  • What is the application you are taking a screenshot of? As Matt has said it can depend on what you are capturing. It could also be you are focusing on a different window when taking the screenshot? – Nashibukasan Apr 24 '12 at 03:21
  • I was hoping taking screenshot of the firefox window. If I see some output, instead of white screen then I would know that I am atleast in the right direction. – satyajit Apr 24 '12 at 18:28

2 Answers2

2

My mistake, I was not using the selenium API correctly. I doubt any one would again do the same mistake again but here is the fix. I did the first call

Screenshot ss=((ITakesScreenshot)driver).GetScreenshot();

in a constructor and second savefile at the place I want to create the screenshot

ss.SaveAsFile("test.png", System.Drawing.Imaging.ImageFormat.Png);

They both should be combined at one place.

satyajit
  • 1,470
  • 3
  • 22
  • 43
0

Perhaps you are taking a screenshot of WebGL object? Traditional screenshots may not work in this case.

Matt
  • 25,943
  • 66
  • 198
  • 303