Geckodrivder allows you to set up a web driver instance in a package like Selenium and control Firefox (and any other Gecko-based browsers).
Documentation
Downloaded a zip from Releases
And move the executable to a bin directory in your PATH.
$ brew install geckodriver