Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

black image is returned while taking IE screenshot in C#

Solved 1 Answers 485 Views Selenium
0 1
I am using C#. I am taking screenshot, but it returns blank. It works on FF and Chrome. It works over grid as well. However while working with IE, either on same PC or remote PC, it returns blank image.

using OpenQA.Selenium;

using OpenQA.Selenium.IE;

using OpenQA.Selenium.Remote;

using OpenQA.Selenium.Support.UI;


static void Main(string[] args)


   IWebDriver NewDriver = null;

   using (NewDriver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.InternetExplorer()))


      if (NewDriver != null)



         NewDriver.Manage().Window.Size = new Size(1804, 1096);

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

         ICapabilities capabilities = ((RemoteWebDriver)NewDriver).Capabilities;

         ss.SaveAsFile(@"C:\Path\123.png", ImageFormat.Png);





1 Answer

Best answer

you may want to try removing below line

//NewDriver.Manage().Window.Size = new Size(1804, 1096);

maximize your browser instead.

answered by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.