selenium webdriver 截屏操作
有时候我们需要进行截屏操作,特别是遇到一些比较重要的页面信息(出现错误)或者出现不同需要进行对比时,
我们就需要对正在处理的页面进行截屏!
未经作者允许,禁止转载!
package test_wait20161205; 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.chrome.ChromeDriver; public class screen_shot20161205 { public static void main(String[] args) throws InterruptedException, IOException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chorme.driver", "C:\\Training\\Automation\\Software\\drivers\\chromedriver_win32\\chromedriver.exe");和上面一行是连着的
WebDriver driver=new ChromeDriver();
driver.get("https://www.hao123.com/");
Thread.sleep(1000); File screenshot=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);-------------------------截屏操作
FileUtils.copyFile(screenshot, new File("C:\\Users\\chenjia\\Desktop\\screenshots1.jpg"));----------保存图片 System.out.println("将截屏的图片保存在桌面"); } }
selenium webdriver 截屏操作的更多相关文章
- selenium webdriver 截屏
/**截图 * @param driver * @param name */ public static void takeScreenShot(WebDriver driver,String nam ...
- iOS 中捕获截屏操作
转自:iOS知识小集 在iOS 7后,苹果提供了UIApplicationUserDidTakeScreenshotNotification通知来告诉App用户做了截屏操作.苹果的描述如下: // T ...
- java selenium webdriver处理JS操作窗口滚动条
未经作者允许,禁止转载!!! java selenium webdriver处理JS操作窗口滚动条 java selenium webdriver处理JS操作窗口滚动条 import org.open ...
- selenium截屏操作(也支持截长图)
1.常用的可能是谷歌和火狐做自动化在抛异常的时候可以截屏保存 from selenium import webdriver br=webdriver.Chrome() br.maximize_wind ...
- nodejs+phantomjs+七牛 实现截屏操作并上传七牛存储
近来研究了下phantomjs,只是初涉,还谈不上深入研究,首先介绍下什么是phantomjs. 官网上的介绍是:”PhantomJS is a headless WebKit scriptable ...
- selenium webdriver(1)---浏览器操作
启动浏览器 如何启动浏览器已在上篇文章中说明,这里还是以chrome为例,firefox.IE启动方式相同. //启动浏览器 import org.openqa.selenium.WebDriver; ...
- selenium webdriver python 元素操作
常用操作 click 点击某个元素 driver.find_element_by_id(“su”).click() clear driver.find_element_by_id(“kw”).cl ...
- Python selenium webdriver设置js操作页面滚动条
js2 = "window.scrollTo(0,0);" #括号中为坐标 当不知道需要的滚动的坐标大小时: weizhi2 = driver.find_element_by_id ...
- win10自带截屏操作
1.win+shift+S,自由截屏 2.win+W,截屏后编辑 3.alt+PrtSc,截取当前活动界面,鼠标在微信就是微信,在浏览器就是浏览器.在桌面就是所有界面. 4.PrtScn,截取所有屏幕 ...
随机推荐
- 0R的电阻以及NC的意义
0欧电阻的作用: 0欧的电阻大概有以下几个功能:①做为跳线使用.这样既美观,安装也方便.②在数字和模拟等混合电路中,往往要求两个地分开,并且单点连接.我们可以用一个0欧的电阻来连接这两个地,而不是直接 ...
- icon VS html特殊字符
好久没来了,最近项目很多,今天要说的是个页面上用到的icon. 话“icon” 现在有很多icon库,我们再也不用切图来适配不同的分辨率了,但是对于新手来说,查阅icon库来找到适合的icon,实在费 ...
- Elasticsearch学习之相关度评分TF&IDF
relevance score算法,简单来说,就是计算出,一个索引中的文本,与搜索文本,他们之间的关联匹配程度 Elasticsearch使用的是 term frequency/inverse doc ...
- @components问题
场景:在引入组件的时候,希望解决"../components/page/member"这样的引入: 希望:像vue的项目中用@components/page/member引入组件 ...
- CentOS 安装apache
yum 安装apache yum –y install httpd 设置开机启动 chkconfig --levels 235 httpd on 启动 /etc/init.d/httpd start ...
- python添加Windows环境变量
1.cmd中添加方式 SET PATH=%PATH%;c:\Program Files (x86)\Wireshark 注:如上代码添加c:\Program Files (x86)\Wireshark ...
- ElasticSearch 安装 go-mysql-elasticsearch 同步mysql的数据
一.首先在Centos6.5上安装 go 语言环境 下载Golang语言包:https://studygolang.com/dl [hoojjack@localhost src]$ ls apache ...
- vue报错 Module not found: Error: Cannot resolve 'file' or 'directory'
炸了,我好写sell而组件,直接就用了,我的天哪 看你的写了吗,就用: Module not found: Error: Cannot resolve 'file' or 'directory' 页另 ...
- SPOJ Distinct Substrings【后缀数组】
Given a string, we need to find the total number of its distinct substrings. Input T- number of test ...
- MapReduce的洗牌(Shuffle)
Shuffle过程:数据从map端传输到reduce端的过程~ Map端 每个map有一个环形内存缓冲区,用于存储任务的输出.默认大小100MB(io.sort.mb属性),一旦达到阀值0.8(io. ...