Chickenfoot Utility Functions

From Chickenfoot Script Repository


Table of contents

Dump current HTML

Dumps the current HTML of the page to a file. You can optionally scrub all of the <script> tags before dumping the HTML. This is helpful getting the HTML of a page that is dynamically generated with JavaScript and working with it offline. For such pages, the HTML source is often too barebones to be useful, and the "Save Page As..." option is not reliable enough to do this on its own (it has been a problem for me, in practice).

Calling Java Swing from Chickenfoot

Yes, you can call Java from Chickenfoot, so here's an example of opening a JFrame and adding a button and a label to it. This isn't very practical, but it's here just to show that it can be done.

Exact Find =

A function, exactfind(), which returns whether a string is exactly found in a page or not. Also uses strip_tags().

Get the largest image on a page

This script grabs the largest image on a page, making it easy to grab things such as the logo from the Google home page.

Handling popup windows

Chickenfoot doesn't automatically switch to popup windows (yet). Here's a workaround.

Handling alert or confirm windows

Chickenfoot doesn't have a command to close alert or confirm windows. Here's a workaround.

Running code whenever an AJAX page changes

Trigger scripts that trigger on a page load aren't as useful on AJAX web sites where the URL never changes. Here's a useful function that allows you to run some code every time the page's contents are changed, even though no page load occurs.

Simple load test on a web page

This script shows how chickenfoot can be used to load test a given web page.

Web site testing

This script shows how chickenfoot can be used to automate web site testing. It keeps track of the loading time for each step in the use case, and saves the HTML of each step to a file.

Launch chickenfoot scripts from command line without X

chickenfoot-launcher is a helper to run chickenfoot scripts from command line without X so that they can be used from e.g. cron jobs easily. Internally it starts a VNC server and runs firefox with a fake home directory so that it does not ever affect simultaneous interactive firefox use. It passes command line arguments and contents of stdin/stdout via temporary files due to javascript limitations. Source code, minimal documentation and a few examples are available at http://iki.fi/lindi/darcs/chickenfoot/