好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

webkitdriver

webkitdriver

webkitdriver

WebDriver implementation for a headless/embedded WebKit based browser

http://blog.mozilla.com/ted/2010/07/29/moz-headless-screenshot/


Ted’s Mozilla Blog

If this were a diary it would have a unicorn on the cover, because unicorns are awesome.

moz-headless-screenshot

July 29th, 2010

On a  personal project of mine , I have a need to generate thumbnails of web pages. Until recently my solution was to use  Firefox  running in  Xvfb , a virtual X server. This is not an ideal solution, as it requires you to have lots of X client libraries installed on your server. Additionally, Firefox is not intended for this purpose, so there are lots of ways for things to go wrong.

Because of this, I’d been following  Chris Lord ‘s work on the offscreen branch  of Mozilla for some time, but never tried it out until recently. The offscreen branch provides a widget backend for Mozilla that can render web content to an offscreen buffer. Chris wrote it in support of  Clutter , which is a pretty neat use case. Conveniently, he also provided a sample embedding client application called moz-headless-screenshot. This is a simple command line tool that takes a URL, image size, and output filename and generates a PNG screenshot of the webpage. This being exactly what I wanted, and having my poorly-written Firefox+Xvfb solution fall apart due to a server migration, I decided to give his solution a shot.

I hit a few speed bumps on the way, since there wasn’t much documentation to be found on actually building and using moz-headless-screenshot. I’ve attempted to fix this my providing detailed steps and a Makefile  in  my own moz-headless-screenshot repository . I’ve also modified the code slightly such that it’s easier to run (at least in my use case). I have heard from others over the years that have this same need, so hopefully someone else finds it useful!

6 Comments ?

6 Responses to “moz-headless-screenshot” therube  Says: 
July 29th, 2010 at 12:37 pm

If I’m understanding, this should work similarly for a Windows user:

Nirsoft: [url=http://www.nirsoft.net/utils/web_site_screenshot.html]SiteShoter – Take a screenshot of a Web site [/url]

“SiteShoter is a small utility that allows you to save a screenshot of any Web page into a file. It automatically creates hidden window of Internet Explorer, loads the desired Web page, and than save the entire content of the Web page into an image file (.png, .jpg, .tiff, .bmp or .gif).

You can also use SiteShoter to convert .html file on your local drive into image file.

You can use SiteShoter in user interface mode, or alternatively, you can run SiteShoter in command-line mode without displaying any user interface.”

Rob Helmer  Says: 
July 29th, 2010 at 2:59 pm

This is very useful to me, thanks for blogging about this!

For work I put together a website-to-PDF script using Firefox and Xvnc on Linux (easier to debug problems than Xvfb IMHO) but it’s a PITA all around, it’d be nice to have fewer moving parts for sure.

voracity  Says: 
July 29th, 2010 at 11:55 pm

I’ve been using wkhtmltopdf for, well, exactly what the name says. That uses Webkit, but it would be wonderful to have something Gecko based.

woro  Says: 
July 30th, 2010 at 12:13 am

Hmm, what’s wrong with gnome-web-photo which is also using Gecko (in certain builds)?

tmielczarek  Says: 
July 30th, 2010 at 11:32 am

gnome-web-photo has additional dependencies on Gnome libs which I don’t want to install. Also, it still needs an X server, AFAICT. (Although if it was built against the offscreen branch, it might not.)

Chris Lord  Says: 
August 3rd, 2010 at 6:25 am

Awesome, glad some people have found use for it   Would be great if someone picked up the work and managed to get it into master…

 

 

 

 

 

 

http://www.holovaty.com/writing/headless-html-rendering-engine/

http://mink.behat.org/#understanding-the-mink

Mink

MINK.PHAR VIEW ON GITHUB VIEW PEAR REPO

CHAPTERS Installation Method #1 (PEAR) Method #2 (PHAR) Method #3 (Git) Understanding the Mink Different Browsers - Drivers GoutteDriver SahiDriver ZombieDriver Control the Browser - Session Basic Browser Interaction Cookies and Headers management HTTP Authentication Resetting the Session Sessions Manager Traverse the Page - Selectors Named Selectors CSS Selectors XPath Selectors find*  Methods Nested Traversing Manipulate the Page - NodeElement Element Content and Text Form Field Maniupaltions Mouse Manipulations Drag’n’Drop Testing Tools Integration Mink API

Web acceptance testing

One of the most important parts in the web is a browser. Browser is the window, through which web users interact with web applications and other users. Users are always talks with web applications through browsers.

So, in order to test, that our web application behaves correctly, we need a way to simulate this interaction between browser and web application in our tests. We need a  Mink .

Mink is an open source acceptance test framework for web applications, written in PHP 5.3.

Installation

Mink is a php 5.3 library that you’ll use inside your test suites or project. Before you begin, ensure that you have at least PHP 5.3.1 installed.

查看更多关于webkitdriver的详细内容...

  阅读:40次

上一篇: CSS3 backgroundsize 属性

下一篇:解释系统