satyajit
satyajit

Reputation: 1570

Blank white screenshots while taking screenshots with selenium webdriver in C#

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

Upvotes: 3

Views: 4005

Answers (2)

satyajit
satyajit

Reputation: 1570

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.

Upvotes: 2

Matt
Matt

Reputation: 26971

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

Upvotes: 0

Related Questions