Search this site

[prev]  Page 2 of 2





Firefox horizontal scrolling fix

Firefox, by default, seems to be very braindead about horizontal scrolling. It goes back/foreward by default. I want it to scroll. To do this, you need to make two changes to your configuration.

Go to 'about:config' in your URL bar in Firefox. If you've never done this before, literally type 'about:config' in the URL bar and hit enter. This will bring up a list of user settings. In the search bar, type 'mouse' and change the following values:

mousewheel.horizscroll.withnokey.action - Set this to '1'
mousewheel.horizscroll.withnokey.numlines - Set this to '1'
The action defaults to 2, which means go forward/back. Annoying.

The numlines defaults to -1, which scrolls left when you use the mouse to attempt scrolling right. Setting it to 1 will make it scroll left when you scroll left, as it should.

Voila! Horizontal scrolling should now work properly.

Xvfb + Firefox

Resig has a bunch of unit tests he does to make sure jQuery works properly on whatever browser. Manually running and checking unit test results is annoying and time consuming. Let's automate this.

Update (May 2010): See this post for more details on automating xserver startup without having to worry about display numbers (:1, :2, etc).

Combine something simple like Firefox and Xvfb (X Virtual Frame Buffer), and you've got a simple way to run Firefox without a visible display.

Let's start Xvfb:

startx -- `which Xvfb` :1 -screen 0 1024x768x24

# Or with Xvnc (also headless)
startx -- `which Xvnc` :1 -geometry 1024x768x24

# Or with Xephyr (nested X server, requires X)
startx -- `which Xephyr` :1 -screen 1024x768x24

This starts Xvfb running on :1 with a screen size of 1024x768 and 24bits/pixel color depth. Now, let's run firefox:
DISPLAY=:1 firefox

# Or, if you run csh or tcsh
env DISPLAY=:1 firefox
Seems simple enough. What now? We want to tell firefox to go to, perhaps.
DISPLAY=:1 firefox-remote
Now, let's take a screenshot (requires ImageMagick's import command):
DISPLAY=:1 import -window root googledotcom.png
Lets see what that looks like: googledotcom.png

While this isn't complicated, we could very easily automate lots of magic using something like the Selenium extension, all without requiring the use of a visual display (Monitor). Hopefully I'll find time to work on something cool using this soon.

Problems with screen scraping and other website interaction automation is that it almost always needs to be done without a browser. For instance, all of my screen scraping adventures have been using Perl. Browsers already know how to speak to the web, so why reinvent the wheel?

Firefox has lots of javascript-magic extensions such as greasemonkey and Selenium to let you execute browser-side javascript and activity automatically. Combine these together with Xvfb, and you can automate lots of things behind the scenes.

Tie this back to unit tests. Instead of simply displaying results of unit tests, have the page also report the results to a cgi script on the webserver. This will let you automatically test websites using a web browser and have it automatically report the results back to a server.

Firefox, Greasemonkey, and

I got bored and decided to play with greasemonkey. The results are somewhat crude but it works and I think I like it better than my current solution to interface with


Requires: Firefox, the greasemonkey extension, and a account (free)

For those out of the Know: Greasemonkey is a sexy extension for Firefox that lets you execute "user" scripts whenever a page loads. This lets you add functionality, remove banner adds, clean up pages, change themes, etc of pages you are viewing. This prospect is extremely exciting.

Since the Mozilla family support xpath and other neat things in its javascript engine, you can do huge set of actions on the pages you view. This includes using xpath to find advertisements and deleting those elements, for instance. The possibilities are potentially limitless. I highly recommend people having a gander.

Go to GreaseMonkey