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

0
black image is returned while taking IE screenshot in C#

Solved 1 Answers 470 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.Navigate().GoToUrl("http://www.google.com");

         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);

         NewDriver.Quit();

       }

    }

 }

1 Answer

-1
Best answer
-1

you may want to try removing below line

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

maximize your browser instead.

NewDriver.Manage().Window.Maximize();
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.
...