package util; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import java.io.File; import java.io.IOException; import java.util.Date; public class ScreenShotUtil { public WebDriver driver; public ScreenShotUtil(WebDriver driver) { this.driver = driver; } /**截图并存储到screenPath * * @param driver * @param screenPath */ private static void takeScreenshot(WebDriver driver, String screenPath) { try { File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File(screenPath)); } catch (IOException e) { System.out.println("Screen shot error: " + screenPath); } } /**截图并存储到固定目录下test-output/snapshot中 * * @param driver 浏览器驱动 */ public void takeScreenshot(WebDriver driver) { String screenName = String.valueOf(new Date().getTime()) + ".jpg"; File dir = new File("test-output/snapshot"); if (!dir.exists()) dir.mkdirs(); String screenPath = dir.getAbsolutePath() + "/" + screenName; this.takeScreenshot(driver, screenPath); } }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算