zoukankan      html  css  js  c++  java
  • 窗口截图

    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();
            }
        }
    }
  • 相关阅读:
    python 标准库和第3方库的介绍
    delphi延时函数
    delphi控件的安装
    Hadoop 第一课:linux常用命令
    复习 struts1 开发步骤
    struts学习:传统方法完成struts注册表单校验与回显数据
    struts入门第一个案例
    Java Ant build.xml详解
    HTTP 方法:GET 对比 POST
    HTTP 返回的状态消息
  • 原文地址:https://www.cnblogs.com/cmm2016/p/5595895.html
Copyright © 2011-2022 走看看