当我打开.jpeg文件时,它是空白的。
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver","C:\\Users\\allan\\workspace\\Login\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:\\screenshots\\screenshot.jpeg"));
driver.get("https://www.facebook.com/");
}
答案 0 :(得分:0)
您在导航到任何网站之前都会截取屏幕截图。
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver","C:\\Users\\allan\\workspace\\Login\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:\\screenshots\\screenshot.jpeg"));
}