0

Does anybody know how to make full screenshot of display using webdriver? In Selenium documentation I read that it is possible: (http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/TakesScreenshot.html)

..

  • The screenshot of the entire display containing the browser
  • ..

    I use Selenium Grid. My hub is on linux and node on windows. I tried to use Robot, however it takes screenshot on linux, however needs on windows

    • You need more information; there really isn't a question here. For example, what have you tried? Do you have any code that you have written? If so, post it! – Brian Apr 27 '16 at 13:42

    3 Answers3

    0

    If you want a screenshot of your currently running browser instance then you can do it using following code:

      public static void captureScreen(WebDriver driver, String screenshotFileName)
        {
            String screenshotsFile = screenshotsFolder+screenshotFileName+imageExtention;
    
            try {
                File screenShot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
                FileUtils.copyFile(screenShot, new File(screenshotsFile));
            } catch (IOException e) {
    
            }
        }
    

    But if you want to take screenshot of your active window (other than browser only) then you can use Robot class.

    Edit:

    Although it's too late for you, the link below contains your answer. I think it may be helpful for others who are searching for the same thing. Screen shot issue in selenium webdriver

    Community
    • 1
    • 1
    optimistic_creeper
    • 2,739
    • 3
    • 23
    • 37
    • Yes, I need to take screenshot of my active window. However my hub is on Linux and Nodes are on Windows. So Robot takes screenshot on linux – Mykola Svyshch Apr 27 '16 at 14:17
    0

    You need to use FirefoxDriver to screenshot whole page. Chrome and IE doesn't support it.

    celikgumusdag
    • 25
    • 1
    • 1
    • 8
    -1

    hi try it like below it will take the complete webpage screen shot

     File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
     //The below method will save the screen shot in defined drive with name "screenshot.png"
     FileUtils.copyFile(scrFile, new File("yourPath\\screenshot.png"));
    
    Rajnish Kumar
    • 2,828
    • 5
    • 25
    • 39