Selenium webdriver实现截图功能
可参考http://www.cnblogs.com/tobecrazy/p/3599568.html
Webdriver截图时,需要引入:
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot; 截图方法
public static void snapshot(TakesScreenshot drivername, String filename)
{
// this method will take screen shot ,require two parameters ,one is driver name, another is file name
String currentPath = System.getProperty("user.dir"); //get current work folder
System.out.println(currentPath);
File scrFile = drivername.getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
try {
System.out.println("save snapshot path is:"+currentPath+"/"+filename);
FileUtils.copyFile(scrFile, new File(currentPath+"\\"+filename));
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Can't save screenshot");
e.printStackTrace();
}
finally
{
System.out.println("screen shot finished");
}
} 在百度上搜索 selenium 然后截图
Selenium webdriver实现截图功能的更多相关文章
- Selenium Webdriver——实现截图功能
截图方法 public static void snapshot(TakesScreenshot drivername, String filename) { // this method will ...
- selenium提供的截图功能
get_screenshot_as_file()提供一个截屏功能.在自动化执行过程中,执行失败后只能看到代码的运行错误,而不能直接看到ui上的错误,利用截屏保存下来很容易的进行问题的判断 先来执行一个 ...
- Selenium Webdriver 自动化测试开发常见问题(C#版)
转一篇文章,有修改,出处http://www.7dtest.com/site/blog-2880-203.html 1:Selenium中对浏览器的操作 首先生成一个Web对象 IWebDriver ...
- Selenium2学习-023-WebUI自动化实战实例-021-获取浏览器显示区域大小,通过 WebDriver 截图功能
之前的博文 020-JavaScript 在 Selenium 自动化中的应用实例之二(获取浏览器显示区域大小) 简述了通过 JavaScript 获取浏览器显示区域大小,此文将简述另一种获取浏览器显 ...
- selenium + python实现截图并且保存图片
webdriver的截图功能十分强悍,无论页面多长,webdriver都能比较完美的截到完整的页面. python代码: # -*- coding: utf-8 -*-from selenium im ...
- 封装selenium自动化框架中的截图功能
对selenium自带的截图功能进行封装: 以下为封装的代码,自定义一个.py文件即可,图片路径自己设置一个. #coding:utf-8 class Screen(object): ''' 封装的截 ...
- selenium截图功能
selenium自动化测试完后需要查看值观的结果,或者查操作过程中是否正确,此时需要使用自带的截图功能. 示例1: from time import sleep from selenium impor ...
- selenium web driver 实现截图功能
在验证某些关键步骤时,需要截个图来记录一下当时的情况 Webdriver截图时,需要引入 import java.io.File; import java.io.IOException; import ...
- Selenium webdriver 截图 太长截不全的问题
Selenium webdriver 截图 太长截不全的问题 1.环境 selenium webdriver.net 2.46.0.0 + firefox 37.0.1 + win 8.1 2.问题 ...
随机推荐
- WeakHashMap回收时机结合JVM 虚拟机GC的一些理解
一直很想知道WeakHashMap的使用场景,想来想去只能用在高速缓存中,而且缓存的数据还不是特别重要,因为key(key不存在被引用的时候)随时会被回收 所以研究了一下WeakHashMap的回收时 ...
- jVM笔记4-对象的结构
1.对象的结构有: 1.Header(对象头),其组成主要有两部分: 1.自身运行时的数据(Mark Word),包括: 1.哈希值 2.GC分代年龄. 3.锁状态标志 4.线程所持有的锁 5.偏向线 ...
- SQL2005查询死锁的表和具体的语句
查是哪个进程死锁了哪些表 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName fro ...
- day6(列表操作、列表练习题)
一.列表操作 a) 循环 基本语法 for i in value : L1 =['a','b','c','d',1,2,3,4,5,6,'b','D'] for i in L1: print(i) ...
- Ubuntu版本更替所引发的“血案”
Ubuntu版本更替所引发的"血案" 今天,我兴致很高的装了双系统,并且配置了Linux的网络,接下来就是安装一些软件,来实现我想达到的功能了,结果被一个小小的命令卡的 ...
- 面试题:HTTP与HTTPS
记录个面试题 HTTP与HTTPS的不同 1.HTTP的URL为http://开头,HTTPS的URL为https://开头 2.HTTP标准端口80,HTTPS标准端口是443 3.在OSI网络模型 ...
- 使用ffserver实现转发实时流媒体(摄像头捕获)
本系统为ubuntu 10.04LTS 说明1:本实验在本机成功测试通过: 说明2:本实验仅仅测试了视频流,未测试音频流. 1.配置ffserver.conf -------------------- ...
- freemarker.core.InvalidReferenceException
1.错误描述 freemarker.core.InvalidReferenceException:on line 68,column 18 in ftl/inc/incPro.ftl p.mainSe ...
- 芝麻HTTP:redis-py的安装
对于Redis来说,我们要使用redis-py库来与其交互,这里就来介绍一下它的安装方法. 1. 相关链接 GitHub:https://github.com/andymccurdy/redis-py ...
- CF367 E - Working routine
十字链表模拟 #include<bits/stdc++.h> using namespace std; int n,m,q; struct Node{ int v; int d,r; }m ...