power_settings_new

black image is returned while taking IE screenshot in C#

by
asked
0 like 0 dislike
522 views
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();

       }

    }

 }

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.

1 Answer

answered by
0 like 1 dislike
 
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();
add
...