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=utf8
import os,traceback
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from 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模式渲染网页的更多相关文章

  1. selenium +chrome headless Manual 模式渲染网页

    可以看看这个里面的介绍,写得很好.https://duo.com/blog/driving-headless-chrome-with-python from selenium import webdr ...

  2. ubuntu服务器端使用无界面selenium+ chrome + headless

    本来想直接用Ubuntu系统里面的firefox来实现selenium自动操作签到的,但是总是出各种问题.没办法,改为Chrome.参考:Ubuntu 线上无界面服务器 使用selenium chro ...

  3. 笔记-selenium+chrome headless

    笔记-selenium+chrome headless 1.      selenium+chrome headless phantomjs与selenium分手了,建议使用其它无头浏览器. chro ...

  4. chrome浏览器爬虫WebDriverException解决采用python + selenium + chrome + headless模式

    WebDriverException: Message: unknown error: Chrome failed to start: crashed 第一种:如果出现下面情况: chrome浏览器有 ...

  5. selenium chrome headless无界面引擎

    注意:PhantomJS已被舍弃 chrome headless 在打开浏览器之前添加参数 import time import sys from selenium import webdriver ...

  6. Selenium + Chrome headless 报ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context 可忽略并配置不输出日志

    Selenium不再推荐使用PhantomJS,会报如下警告 UserWarning: Selenium support for PhantomJS has been deprecated, plea ...

  7. ubuntu中如何安装selenium+chrome(headless)无界面浏览器?

    selenium是一个Web的自动化测试工具,它可以根据我们的指令,让浏览器自动加载页面,获取需要的数据,甚至页面截屏,或者判断网站上某些动作是否发生.但是它自身不带浏览器,不支持浏览器的功能,因此它 ...

  8. Ubuntu 无界面使用selenium chrome + headless

    1. 安装 selenium : sudo pip install selenium 2. 安装 chromdriver: 进入 淘宝镜像源 下载 chromdriver, 可以查看 notes.tx ...

  9. 关于强制IE不使用兼容模式渲染网页

    现在IE11是唯一受微软支持的IE浏览器. IE11有兼容模式,开启后有网页会出错. 在html header标签下加上 <meta http-equiv="X-UA-Compatib ...

随机推荐

  1. Linxu 安装Nignx

    http://www.myhack58.com/Article/sort099/sort0102/2014/44894.htm 1.为了追加 nginx 的 yum 仓库,需要创建一个文件 /etc/ ...

  2. java.io.ByteArrayOutputStream 源码分析

    ByteArrayOutputStream 内部包含了一个缓冲区,缓冲区会随着数据的不断写入而自动增长,俗称内存流. 首先看一下俩个属性,buf是内部缓冲区,count是记录写入了多少个字节. pro ...

  3. Vagrant (3) —— 复制/备份Vagrant Box

    Vagrant (3) -- 复制/备份Vagrant Box 摘要 介绍复制/备份Vagrant Box基本方法 版本 Vagrant版本: 1.8.1 内容 复制vagrant box并压缩 关闭 ...

  4. 妙用CTE,一条语句实现sql递归查询,SQLServer 递归

    数据库设计中经常碰到父子节点的关系结构,经常需要找到某个节点的根,或者某个节点的所有子节点,一般做法都是在业务层做递归的方式实现,或者数据库存储过程实现.但其实SQLServer提供的CTE可以很好的 ...

  5. 【嵌入式】——对#define GPBCON (*(volatile unsigned long*)0x56000010)的理解

    #define GPBCON (*(volatile unsigned long*)0x56000010) 1:volatile 当计算机需要一个数值的时候,会先把内存中的值读取到寄存器,然后下次在使 ...

  6. 【oneday_onepage】——China's Internet users grow to 591 million

    July 17, 2013, 6:29 AM — China's Internet populace grew to 591 million by the end of June, as more n ...

  7. spring sringboot 加载配置文件 多目录配置文件 多级分类配置文件

    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource[] resources = ...

  8. Jackson 处理复杂类型(List,map)两种方法

    http://blog.csdn.net/zhuyijian135757/article/details/38269715 —————————————————————————————————————— ...

  9. 高通 打开 wifi 驱动 log

    在WCNSS_qcom_cfg.ini文件中添加 vosTraceEnableSME=255 vosTraceEnableWDI=255 vosTraceEnableWDA=255 vosTraceE ...

  10. Google File System 学习

    摘要 Google的人设计并实现了Google File System,一个可升级的分布式文件系统,用于大的分布式数据应用.可以运行在廉价的日用硬件上,具备容错性,且为大量客户端提供了高聚合的性能. ...