Install Selenium + NodeJS + geckodriver (Firefox) on MacOS

Sabtu, 11 November 2023, 4:45 pm0

Previously I used Selenium in NodeJS environment with Chrome , but because of Google updated Chrome regularly, its webdriver wasn’t updated quickly enough.

Firefox running in automated mode.

I couldn’t figure out how to disable Chrome auto update, and an outdated webdriver doesn’t work with new version of Chrome. So I decided to switch to using Firefox and its webdriver, named geckodriver.

Chrome webdriver ( latest version as of November 2023:

  • webdriver = 114.0.5735.90
  • Chrome = 119.0.6045.123
  • major version must match (114 vs 119)


Install geckodriver:

  • Download compiled binary from, latest version as of November 2023 – geckodriver-v0.33.0-macos.tar.gz
  • Untar it & move geckodriver to /usr/local/bin/
  • Or, can put it in any folder & add that folder to $PATH environment variable:
    • I put it in ~/Documents/geckodriver/ folder
    • Edit ~/.zshrc, add export PATH=$PATH:~/Documents/geckodriver
    • run source ~/.zshrc in terminal to update the environment variable values

Try run geckodriver, if it’s showing dialog similar like below, this one is when I try to run chromedriver:

Cannot be opened because the developer cannot be verified.

To solve this, go to System Preferences > Security & Privacy > Allow apps downloaded from, click Allow Anyway.

Create NodeJS app & using selenium-webdriver node module:

mkdir myapp
cd myapp
npm init -y
npm install selenium-webdriver

To test the installation, create test.js insider myapp folder, and copy the source code from this gist:

  • open one tab in Terminal, and run geckodriver
  • In another tab, run test.js: node test.js

Komentar (0):


Tulis komen: