webkitdriver


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 theoffscreen 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 providingdetailed 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 Responses to “moz-headless-screenshot”

  1. therube Says: 

    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.”

  2. Rob Helmer Says: 

    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.

  3. voracity Says: 

    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.

  4. woro Says: 

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

  5. tmielczarek Says: 

    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.)

  6. Chris Lord Says: 

    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

    CHAPTERS

    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.

 

posted on 2011-10-28 09:28  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2011/10/28/2227268.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jBrowserDriver是一款采用纯Java编写的无图形化浏览器,基于WebKit,和Selenium兼容。通过Maven安装:<dependency>   <groupId>com.machinepublishers</groupId>   <artifactId>jbrowserdriver</artifactId>   <version>0.16.1</version> </dependency>使用示例代码:import org.openqa.selenium.WebDriver; import com.machinepublishers.jbrowserdriver.Timezone; import com.machinepublishers.jbrowserdriver.JBrowserDriver; import com.machinepublishers.jbrowserdriver.Settings; public class Example {   public static void main(String[] args) {     // You can optionally pass a Settings object here,     // constructed using Settings.Builder     JBrowserDriver driver = new JBrowserDriver(Settings.builder().       timezone(Timezone.AMERICA_NEWYORK).build());     // This will block for the page load and any     // associated AJAX requests     driver.get("http://example.com");     // You can get status code unlike other Selenium drivers.     // It blocks for AJAX requests and page loads after clicks      // and keyboard events.     System.out.println(driver.getStatusCode());     // Returns the page source in its current state, including     // any DOM updates that occurred after page load     System.out.println(driver.getPageSource());     // Close the browser. Allows this thread to terminate.     driver.quit();   } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值