selenium icon indicating copy to clipboard operation
selenium copied to clipboard

codes for screen shot can be executed successfully, some of pictures are good, some of them are black image

Open oceanchow opened this issue 10 years ago • 1 comments

Environment: hub/node, they are** Virtual Machine**, windows 7 x64, ie11, Selenium version:2.48.2 codes

if(driver instanceof RemoteWebDriver){
            WebDriver augmentedDriver = new Augmenter().augment(driver);
            tsDriver = (TakesScreenshot) augmentedDriver;
            logger.info("screenshot: Remote WebDriver");
        }
        else {
            tsDriver = (TakesScreenshot) driver;
            logger.info("screenshot: Local WebDriver");
        }
        File temFile = tsDriver.getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(temFile, new File(filePath));

Anyone can help me with it?

oceanchow avatar Feb 29 '16 08:02 oceanchow

if there's another window in front of IE when the screenshot is taken you will end up with the black screenshot image.

You can try to add the DesiredCapability InternetExplorerDriver.REQUIRE_WINDOW_FOCUS to true. But this does not guarantee the window will be the front most when you take screenshots, but will likely fix you most of the time.

lukeis avatar Feb 29 '16 17:02 lukeis