Created
January 7, 2020 05:48
-
-
Save leewin12/bb4cc16bf939890bfc37203130eb806c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def testScreenshot() { | |
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Greg\\Downloads\\chromedriver79.exe") | |
new File("screenshot.png").withOutputStream { | |
ChromeOptions options = new ChromeOptions() | |
options.headless = true | |
WebDriver driver = new ChromeDriver(ChromeDriverService.createDefaultService(), options) | |
try { | |
driver.get("https://www.google.com") | |
it.write(driver.getScreenshotAs(OutputType.BYTES)) | |
} finally { | |
driver.close() | |
driver.quit() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment