Search code examples
seleniuminternet-explorerwebdriverscreenshot

Using Selenium ITakeScreenshot returns Black Screen from IE Window?


i have a Class Library.dll with some SpecFlow tests written in C# / Selenium, when i am using the standard code to capture the screenshot with selenium class the file is just black window ?!

i have ran previous built solutions & .dll that uses the same driver versions (Selenium.IE32) and Browser Versions and it is capturing the screen fine... i am using the following code.

   ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(ScreenName, ScreenshotImageFormat.Png);

I have considered using the Rectangle/Bitmap to capture the entire screen but this seems to be within the System.Windows.Forms Namespace so i cannot use this in assembly type ClassLibrary.

any ideas?


Solution

  • I took out

    driver.Navigate().GoToUrl(StartURL);
    

    And replaced with

    options.InitialBrowserUrl = StartURL;
    

    This is now capturing valid screenshots!