I'm assuming you're on a recent version of OS X with a blazing fast Net connection. These instructions are based on those given by @AutomatedTester
We begin by checking out and building geckodriver. Note: I've had conflicting suggestions from Mozillians about enabling artifact builds. For now, I've disabled them
hg clone https://hg.mozilla.org/mozilla-central/
cd mozilla-central
./mach bootstrap
# Add this to enable (faster!) artifact builds
#echo "ac_add_options --enable-artifact-builds" >> .mozconfig