码迷,mamicode.com
首页 > 编程语言 > 详细

selenium测试(Java)--截图(十九)

时间:2017-08-05 11:44:42      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:str   nbsp   sel   apach   try   文件   trace   put   rac   

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();
        }

    }

}

 

selenium测试(Java)--截图(十九)

标签:str   nbsp   sel   apach   try   文件   trace   put   rac   

原文地址:http://www.cnblogs.com/xinxin1994/p/7289592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!