博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
webdriver和androidDriver截屏功能
阅读量:7013 次
发布时间:2019-06-28

本文共 921 字,大约阅读时间需要 3 分钟。

    //android截屏功能

    public static String screenshot(AndroidDriver driver) {
        Date dt = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        File screen = driver.getScreenshotAs(OutputType.FILE);
        File screenFile = new File("D:\\screen\\" + sdf.format(dt) + ".png");
        try {
            FileUtils.copyFile(screen, screenFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sdf.format(dt);
    }

 

webdriver:

    public static String screenshot(WebDriver driver) {

        Date dt = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
//        File screen = driver.getScreenshotAs(OutputType.FILE);
        File screenFile = new File("E:\\screen\\" + sdf.format(dt) + ".png");
        try {
            FileUtils.copyFile(srcFile, screenFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sdf.format(dt);
    }

转载于:https://www.cnblogs.com/hxm154/p/7889419.html

你可能感兴趣的文章
mysql_replication(主从复制)
查看>>
收到折扇礼物开心~~
查看>>
Java多线程知识点整理(线程间通信)
查看>>
raid1 raid2 raid5 raid6 raid10的优缺点和做各自raid需要几块硬盘
查看>>
右侧扩展栏效果实现
查看>>
//输出电脑系统的年月日星期以及时间
查看>>
Mysql主从复制及读写分离的实现
查看>>
哈希表的静态,动态,以及key/value形式
查看>>
基于memcached-session-manager的tomcat session共享集群
查看>>
关于Apache的一些配置
查看>>
Hadoop 1.2.1 (centos 6.4下) 伪分布模式下安装
查看>>
SpringMVC的重定向(redirect:)
查看>>
Nginx日志过滤使用ngx_log_if不记录特定日志
查看>>
TCP/IP会话与状态
查看>>
sed删除中文字符
查看>>
MongoDB基本命令用
查看>>
react技术分享(归纳总结)
查看>>
我的友情链接
查看>>
python学习心得-第一天-作业
查看>>
Centos6 iptables防火墙设置
查看>>