selenium +chrome headless Adhoc模式渲染网页
mannual和adhoc模式比较
Manual vs. Adhoc
In the script above, we start the ChromeDriver server process when we create the WebDriver object and it is terminated when we call quit(). For a one-off script, that isn’t a problem, but this can waste a nontrivial amount of time for a large test suite that creates a ChromeDriver instance for each test. Luckily, we can manually start and stop the server ourselves, and it only requires a few changes to the script above.
说的在使用selenium+chromeheadless做自动化测试时候,如果测试用例数量大,给每个测试用例启动一个浏览器要话费更多的时间。 #coding=utf8import os,tracebackfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.chrome.options import Options
service = webdriver.chrome.service.Service('/home/xxxx/Downloads/phantomjs-2.1.1-linux-x86_64/bin/chromedriver')service.start()class ChromeHeadless(object): def __init__(self): chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--disable-images') chrome_options.add_argument('--disable-plugins') chrome_options.binary_location = '/opt/google/chrome/chrome' #prefs = {"profile.managed_default_content_settings.images": 2} # 关图片 #chrome_options.add_experimental_option("prefs", prefs) self.chrome_options=chrome_options self.driver = webdriver.Remote(service.service_url,desired_capabilities=self.chrome_options.to_capabilities()) self.driver.set_page_load_timeout(120) def fun(self,url): try: proxy_http_list = list(r.smembers('kuaidaili:http')) + list(r.smembers('zhima')) pr=random.choice(proxy_http_list) self.chrome_options.add_argument('--proxy-server=%s'%pr) #设置代理 self.driver.start_session(self.chrome_options.to_capabilities()) #print self.driver.session_id self.driver.get(url) except Exception,e: print '\033[7;32;0m%s\033[0m' %traceback.format_exc()
selenium +chrome headless Adhoc模式渲染网页相关推荐
- selenium +chrome headless Manual 模式渲染网页
可以看看这个里面的介绍,写得很好.https://duo.com/blog/driving-headless-chrome-with-python from selenium import webdr ...
- Ubuntu 无界面使用selenium chrome + headless
Ubuntu 无界面使用selenium chrome + headless 1. 安装 selenium : sudo pip install selenium 2. 安装 chromdriver: ...
- Selenium Chrome/Firefox webdriver实现截取网页长图的方法
Selenium Chrome/Firefox webdriver实现截取网页长图的方法 最近在测试使用Selenium+Firefox webdriver来对网页整体截图,由PhantomJS不再更 ...
- 怎样修改html兼容模式代码,禁止IE8使用兼容模式渲染网页的html代码
这两天在调试一个网页,有段html代码在IE8兼容模式下就会显示错乱,而在IE8的标准渲染模式下则显示正常.但是很多浏览器比如360安全浏览器和搜狗浏览器的默认IE内核就是IE8的兼容模式,所以用36 ...
- 强制Edge浏览器以深色模式渲染网页
问题简介 开发者常常需要长时间浏览网页,过亮的页面容易造成视觉疲劳.虽然最新的Windows版本已经支持全局的深色主题,但浏览器渲染网页时,依然会按照网页的默认底色进行页面渲染.这篇文章介绍如何强制E ...
- (转载)Selenium + Chrome headless 报ERROR:gpu_process_transport_factory.cc(1007)]
2019独角兽企业重金招聘Python工程师标准>>> Selenium不再推荐使用PhantomJS,会报如下警告 UserWarning: Selenium support fo ...
- 利用Chrome Headless模式网页转PDF
本文转载于:https://blog.csdn.net/aWDac/article/details/80865754 https://blog.csdn.net/xcl168/articl ...
- python selenium 用法 和 Chrome headless
From: http://cuiqingcai.com/2599.html Selenium教程:https://www.yiibai.com/selenium selenium 官方参考文档:htt ...
- selenium打开chrome浏览器无痕模式
from selenium import webdriver options = webdriver.ChromeOptions() #无痕模式 options.add_argument('--inc ...
最新文章
- 天猫总裁靖捷回答了今年双11的热点问题
- 第十六届全国大学生智能汽车竞赛安徽赛区赛事指南
- 浪潮英特尔在德国发布KEEP升级计划 用户可提前体验英特尔KNM
- java排序算法代码_Java实现八种排序算法(代码详细解释)
- 代码检查规则背景及总体介绍
- 基于DataTabel的增删改查
- Redis 为什么这么快
- 建议看 | 计算机网络核心概念
- 使用React Router v4的嵌套路由
- 从 A/Looper: Could not create epoll instance. errno=24 错误浅谈解决各种 bug 的思路
- 大数据_Flink_流式处理_简介_流数据处理的应用行业---Flink工作笔记0003
- 使用Python批量下载数据
- jquery_datatables
- AndroidStudio使用localMaven
- 现代通信原理思维导图--第二章 确知信号
- 腾讯云轻量应用服务器云硬盘服务简单性能测试
- 项目分析 移动终端自助点餐系统
- sw如何缩放装配体_SolidWorks大装配体技巧
- python画动态小黄鸭_抖音小黄鸭跳舞表情包gif-小黄鸭跳舞表情包动态图片下载无水印完整版-西西软件下载...
- 网站速度和性能测试工具