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模式渲染网页相关推荐

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

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

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

    Ubuntu 无界面使用selenium chrome + headless 1. 安装 selenium : sudo pip install selenium 2. 安装 chromdriver: ...

  3. Selenium Chrome/Firefox webdriver实现截取网页长图的方法

    Selenium Chrome/Firefox webdriver实现截取网页长图的方法 最近在测试使用Selenium+Firefox webdriver来对网页整体截图,由PhantomJS不再更 ...

  4. 怎样修改html兼容模式代码,禁止IE8使用兼容模式渲染网页的html代码

    这两天在调试一个网页,有段html代码在IE8兼容模式下就会显示错乱,而在IE8的标准渲染模式下则显示正常.但是很多浏览器比如360安全浏览器和搜狗浏览器的默认IE内核就是IE8的兼容模式,所以用36 ...

  5. 强制Edge浏览器以深色模式渲染网页

    问题简介 开发者常常需要长时间浏览网页,过亮的页面容易造成视觉疲劳.虽然最新的Windows版本已经支持全局的深色主题,但浏览器渲染网页时,依然会按照网页的默认底色进行页面渲染.这篇文章介绍如何强制E ...

  6. (转载)Selenium + Chrome headless 报ERROR:gpu_process_transport_factory.cc(1007)]

    2019独角兽企业重金招聘Python工程师标准>>> Selenium不再推荐使用PhantomJS,会报如下警告 UserWarning: Selenium support fo ...

  7. 利用Chrome Headless模式网页转PDF

    本文转载于:https://blog.csdn.net/aWDac/article/details/80865754       https://blog.csdn.net/xcl168/articl ...

  8. python selenium 用法 和 Chrome headless

    From: http://cuiqingcai.com/2599.html Selenium教程:https://www.yiibai.com/selenium selenium 官方参考文档:htt ...

  9. selenium打开chrome浏览器无痕模式

    from selenium import webdriver options = webdriver.ChromeOptions() #无痕模式 options.add_argument('--inc ...

最新文章

  1. 天猫总裁靖捷回答了今年双11的热点问题
  2. 第十六届全国大学生智能汽车竞赛安徽赛区赛事指南
  3. 浪潮英特尔在德国发布KEEP升级计划 用户可提前体验英特尔KNM
  4. java排序算法代码_Java实现八种排序算法(代码详细解释)
  5. 代码检查规则背景及总体介绍
  6. 基于DataTabel的增删改查
  7. Redis 为什么这么快
  8. 建议看 | 计算机网络核心概念
  9. 使用React Router v4的嵌套路由
  10. 从 A/Looper: Could not create epoll instance. errno=24 错误浅谈解决各种 bug 的思路
  11. 大数据_Flink_流式处理_简介_流数据处理的应用行业---Flink工作笔记0003
  12. 使用Python批量下载数据
  13. jquery_datatables
  14. AndroidStudio使用localMaven
  15. 现代通信原理思维导图--第二章 确知信号
  16. 腾讯云轻量应用服务器云硬盘服务简单性能测试
  17. 项目分析 移动终端自助点餐系统
  18. sw如何缩放装配体_SolidWorks大装配体技巧
  19. python画动态小黄鸭_抖音小黄鸭跳舞表情包gif-小黄鸭跳舞表情包动态图片下载无水印完整版-西西软件下载...
  20. 网站速度和性能测试工具

热门文章

  1. https加密过程(详细)
  2. Linux服务与chkconfig
  3. 自兴人工智能---认识python语言的基础数据类型和操作
  4. python学习笔记(五)
  5. RT-Thread 学习笔记(四)——添加RTGUI组件
  6. .net开发笔记(十三) Winform常用开发模式第一篇
  7. jQuery+css3实现新年贺卡
  8. Hadoop怎么了,大数据路在何方?
  9. S5PV210裸机之时钟
  10. STM32之通用定时器输入捕获模式