zoukankan      html  css  js  c++  java
  • selenium测试(Java)--截图(十九)

    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();
            }
    
        }
    
    }
  • 相关阅读:
    WebAssembly学习(四):AssemblyScript
    Ramda
    React—生命周期
    网络拓扑图
    手机端的meta信息
    面试题
    Bootstrap路径导航
    Bootstrap 分页翻页
    Bootstrap栅格系统
    Bootstrap 屏幕类型
  • 原文地址:https://www.cnblogs.com/xinxin1994/p/7289592.html
Copyright © 2011-2022 走看看