截图方法:

1 保存截图   get_screenshot_as_file('保存路径\\文件名.png')     #有一个\是转义符

2 保存截图   save_screenshot('保存路径\\文件名.png')

3 转化成base64    get_screenshot_as_base64()

4 转化成二进制串    dr.get_screenshot_as_png()

#coding:utf-8
from selenium import webdriver
import time
dr = webdriver.Chrome()
dr.get("https://www.baidu.com") dr.find_element_by_id('kw').send_keys("selenium screenshot")
#截图
re = dr.get_screenshot_as_file("D:\\baidu.png")
print('截图结果:%s'%re) dr.find_element_by_id('su').click()
time.sleep(2)
#截图
re = dr.save_screenshot("D:\\searchResult.png")
print('截图结果:',re) #base64
print('base64: ',dr.get_screenshot_as_base64())
#binary
print('binary: ',dr.get_screenshot_as_png()) dr.quit()

结果:

Selenium入门15 截图的更多相关文章

  1. 自动化测试Java一:Selenium入门

    From: https://blog.csdn.net/u013258415/article/details/77750214 Selenium入门 欢迎阅读Selenium入门讲义,本讲义将会重点介 ...

  2. Selenium自动化测试Python一:Selenium入门

    Selenium入门 欢迎阅读Selenium入门讲义,本讲义将会重点介绍Selenium的入门知识以及Selenium的前置知识. 自动化测试的基础 在Selenium的课程以前,我们先回顾一下软件 ...

  3. selenium 代理 Cookies 截图 等待 调用JS

    改变用户代理 读取Cookies 调用Java Script Webdriver截图 页面等待 1. 改变用户代理 import org.junit.AfterClass; import org.ju ...

  4. Selenium 入门到精通系列:六

    Selenium 入门到精通系列 PS:Checkbox方法 例子 HTML: <html> <head> <title>测试页面</title> &l ...

  5. Selenium 入门到精通系列:五

    Selenium 入门到精通系列 PS:显式等待.隐式等待.强制等待方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...

  6. Selenium 入门到精通系列:四

    Selenium 入门到精通系列 PS:鼠标右键.鼠标悬停.键盘操作方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...

  7. Selenium 入门到精通系列:三

    Selenium 入门到精通系列 PS:Driver_Element 常用方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2 ...

  8. Selenium 入门到精通系列:二

    Selenium 入门到精通系列 PS:用户登录 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-04-23 16:12 ...

  9. Selenium 入门到精通系列:一

    Selenium 入门到精通系列 PS:控制浏览器窗口大小.前进.后退.刷新 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 20 ...

随机推荐

  1. 基于APPIUM测试微信公众号的UI自动化测试框架(结合Allure2测试报告框架)

    框架初衷 前两周组内的小伙伴跟我说她现在测试的微信公众号项目(保险)每次上新产品时测试起来很费时,存在大量的重复操作(点点点),手工测试每个产品可能需要半天到一天的时间,复杂的产品需要两天. 由于保险 ...

  2. Lucene.Net和盘古分词应用

    Lucene.Net.dll:用做全文索引 PanGu.dll(盘古分词):作为中文分词的条件 大致原理: 1.Lucene先根据PanGu将需要搜索的内容分隔.分词,然后根据分词的结果,做一个索引页 ...

  3. E. Swapping Characters 一个喳喳的做法

    http://codeforces.com/contest/903/problem/E 题意是,对于每个字符串都要交换两个位置的字符(id),使得结果所有字符串是一样的,输出那个字符串. 正解是,先比 ...

  4. Kafka Intro - Configuration

    #Notes: /opt/kafka/config/zookeeper.properties sample # the directory where the snapshot is stored.d ...

  5. 性能测试工具LoadRunner16-LR之Controller 负载运行时设置

  6. 性能测试工具LoadRunner02-LR简介

    使用LoadRunner的步骤 制定性能测试计划-->开发测试脚本-->设计测试场景-->执行测试场景-->监控测试场景-->分析测试结果 LoadRunner由哪些部件 ...

  7. 设置webstorm的file watch 监视scss文件

    参考:http://blog.founddrama.net/2013/04/watching-compass-files-in-webstorm/ 上面红色划线部分. 特别注意arguments: 像 ...

  8. java连接数据库驱动代码综合共享

    1.Oracle8/8i/9i数据库(thin模式)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();S ...

  9. 远程登陆服务器(window系统)

    1,打开命令输入框: 快捷键:win+R 2.输入命令:mstsc 3.输入你的IP地址和用户名(一般为administrator) 4.输入密码

  10. 使用UserLock如何实现工作站登陆访问限制

    UserLock允许用户限制受保护账户可登陆的工作站/终端.工作站/终端限制可以通过设置或者使用特定的IP范围,计算机名/IP或组织单位实现. 对于每个工作站限制你需要指定所要限制的会话类型(默认情况 ...