Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I'm building a console app that will connect to different computers in the network and take browser screenshots of a webpage.

Using Selenium 2.47.1 to set up server & nodes. The console app runs in the PC which is set up as selenium hub.

The screenshot is fine in firefox, chrome, ie from the hub computer.

The screenshot is also fine in firefox in remote pc.

But with IE it returns a black image.

Both the hub and node computers run on windows 7 64-bit, have IE11. I am using the 64bit IEDriver in both PCs. The node computer is not locked.

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://172.165.10.111/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

0 votes
by (62.9k points)

As a result of your screen is locked, or any screensaver is running, taking an IE screenshot returns a black image.

You will need to turn off your screensaver and configure windows to ne'er lock itself once not in use. To turn off your screensaver:

  • Click the Start button.

  • Click Control Panel.

  • In the search box, type screen saver.

  • Click Turn screen saver on or off.

Then modify your screensaver settings. Make sure you have unchecked "On resume, display logon screen".

While you're in the control panel it's probably worth checking the power options and making sure the machine isn't going to sleep or powering down after a set period of time as well.

You will also want to use VNC or remote assist to access the GUI. If you RDP in it will lock the screen for the local user who is currently logged in and again it will lock the screen when you disconnect.

Finally, don't use the 64-bit IE driver, you should be using the 32Bit one. Hardly anyone runs IE Driver’s 64Bit version (even if they need a 64Bit capable machine)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...