博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
selenium测试(Java)--截图(十九)
阅读量:7283 次
发布时间:2019-06-30

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

package com.test.screenshot;import java.io.File;import java.io.IOException;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.firefox.FirefoxDriver;public class ScreenShotTest {    public static void main(String[] args) {        WebDriver driver = new FirefoxDriver();        driver.get("http://www.baidu.com");        //截图到output        File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);        try {            String savePath = "D:\\10-selenium\\workspace\\SeleniumTest"                    + "\\src\\com\\test\\screenshot\\screenshot.png";            //复制内容到指定文件中            FileUtils.copyFile(scrFile, new File(savePath));        } catch (IOException e) {            e.printStackTrace();        }    }}

 

转载地址:http://kkkjm.baihongyu.com/

你可能感兴趣的文章
CF934A A Compatible Pair
查看>>
6.13 判别可作为数值的字符串
查看>>
虚拟内存与物理内存
查看>>
验证ArrayList是线程不安全的集合
查看>>
EPANET源码中用到的几个简单C语言函数介绍一
查看>>
常用位运算
查看>>
eclipse设置jsp默认编码
查看>>
关于servlet
查看>>
fork与vfork的区别
查看>>
HA状态下防火墙损坏处理
查看>>
方位话机同一号码双链路注册实现冗余
查看>>
npm
查看>>
Java compiler level does not match the version of the installed Java project facet.
查看>>
Java加密算法(四)——非对称加密算法RSA
查看>>
sequelize问题集锦
查看>>
cocos2d-x 中 xml 文件读取
查看>>
Vue:计算属性
查看>>
CSS 颜色代码大全
查看>>
Pig和Hive的对比
查看>>
为引用用户控件的在不同页面设置不同样式
查看>>