from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
driver.get('https://www.python.org')
sleep(1)
driver.get_screenshot_as_file("screenshot.png")
driver.quit()
print("end...")
driver.save_screenshot("screenshot.png")
Java
Yes, it is possible. The following example is in Java:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c: mpscreenshot.png"));