Here is some Python code showing WebDriver with a virtual display provided by Xvfb:

#!/usr/bin/env python

from pyvirtualdisplay import Display
from selenium import webdriver display = Display(visible=0, size=(800, 600))
display.start() # now Firefox will run in a virtual display.
# you will not see the browser.
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print browser.title
browser.quit() display.stop()

install PyVirtualDisplay on Ubuntu/Debian:

$ sudo apt-get install xvfb python-pip
$ sudo pip install pyvirtualdisplay

Python - Headless Selenium WebDriver Tests using PyVirtualDisplay的更多相关文章

  1. Python:Selenium+Webdriver安装

    本人小白一枚,今天在使用selenium+webdriver的时候遇到了一个小问题: WebDriverException: 'chromedriver' executable needs to be ...

  2. Python语言-selenium webdriver操作记录汇总

    1.控制浏览器大小 set_window_size() 设置浏览器大小 该方法有两个参数,第一个参数是宽,第二个是高 maximize_window() 设置浏览器全屏显示,无参数 chrome谷歌浏 ...

  3. Selenium - WebDriver: Locating Elements

    Selenium provides the following methods to locate elements in a page: find_element_by_id find_elemen ...

  4. Selenium - WebDriver Advanced Usage

    Explicit Waits # Python from selenium import webdriver from selenium.webdriver.common.by import By f ...

  5. selenium webdriver python 开始

    学习资料: Selenium with Python: http://selenium-python.readthedocs.org/en/latest/index.html 乙醇的python se ...

  6. selenium webdriver (python)的基本用法一

    阅在线 AIP 文档:http://selenium.googlecode.com/git/docs/api/py/index.html目录一.selenium+python 环境搭建........ ...

  7. Python selenium.webdriver.chrome.options.Options() Examples

    The following are 27 code examples for showing how to use selenium.webdriver.chrome.options.Options( ...

  8. chrome headless+selenium+python+(ubuntu 16.04/centos7) 下的实现

    Ubuntu 16.04 下: 0x01 安装chrome 1 下载源加入系统源列表 sudo wget http://www.linuxidc.com/files/repo/google-chrom ...

  9. python利用selenium(webdriver chrome)模拟登陆获取cookie

    (我是在windows下进行实验的) 准备工作: 1.安装python环境. 2.python安装selenium插件(执行以下命令就行).   pip install selenium 3.Wind ...

随机推荐

  1. jq之简单的表单验证

    <body> <form method="post" action=""> <div class="int"& ...

  2. 阶乘相关<同余与模算术>

    题意: 题目很简明: 令S[n]=1*1!+2*2!+3*3!+4*4!+....+n*n! 求S[n]%10000007 多组测试数据 每组一个n n的范围:1<=n<=1000000 ...

  3. Java回调函数的理解

    所谓回调,就是客户程序C调用服务程序S中的某个函数A,然后S又在某个时候反过来调用C中的某个函数B,对于C来说,这个B便叫做回调函数.例如Win32下的窗口过程函数就是一个典型的回调函数.一般说来,C ...

  4. dedecms 的这个dede:arclist里怎么调用全局变量?

    将{dede:global.cfg_templets_skin/} 写为 [field:global.cfg_templets_skin/] 即可.

  5. JAVA基础---面向对象

    方法的重载Overload: 一个类中可以定义有相同的名字, 参数不同的多个方法. 调用时, 会根据不同的参数选择对应的方法. static: 在数据区, 可以计数,属于类,不属于对象: public ...

  6. web前端性能优化指南

    web前端性能优化指南 web前端性能优化指南 概述 1. PC优化手段在Mobile侧同样适用2. 在Mobile侧我们提出三秒种渲染完成首屏指标3. 基于第二点,首屏加载3秒完成或使用Loadin ...

  7. PAT (Advanced Level) 1008. Elevator (20)

    简单模拟. 注意a[i]==a[i-1]的情况. #include<iostream> #include<cstring> #include<cmath> #inc ...

  8. JQuery的插件开发——重点

    1.给JQuery全局对象扩展一个函数方法 $.log=function(){ /* 给全局对象$扩展一个函数*/ } $.log;//调用方法 2.给JQuery普通对象扩展一个函数方法 3.使用第 ...

  9. office web apps部署(一)

    准备两台服务器,A服务器作为域控制器,B服务器安装owa 1.配置域服务器A 参考 2.B服务器加入A所创建的域 参考 3.B服务器安装owa 参考 注意: 1.B服务器加入域后,使用A服务器的管理员 ...

  10. iBATIS 3 试用手记 - The FUTURE - ITeye技术网站

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...