package PublicModel; import java.io.File; import java.io.IOException; //import java.sql.Date; import java.util.Date; import java.text.SimpleDateFormat; import org.testng.TestListenerAdapter; import org.apache.poi.ss.formula.ptg.EqualPtg; import org.openqa.selenium.*; import org.openqa.selenium.interactions.Actions; import Page.element; import org.openqa.selenium.JavascriptExecutor; import Page.DefectTodoElement; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import static org.junit.Assert.assertEquals; import Page.DefectElement; import org.openqa.selenium.interactions.Actions; public class DefecPub { public static void scrshot(TakesScreenshot driver) { // File srcFile=driver.getScreenshotAs(OutputType.FILE); Date currTimeDate = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); String dateString = formatter.format(currTimeDate); try { File srcFile = ((TakesScreenshot) driver) .getScreenshotAs(OutputType.FILE); FileUtils.copyFile(srcFile, new File("E:\workspace\myauto\pic\" + dateString + ".png")); } catch (WebDriverException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }