Cyberithub

How to Install Geckodriver for Selenium in Linux

Advertisements

In this article, I will take you through the steps to install Geckodriver for Selenium in Linux using 4 simple steps. Geckodriver acts as a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers. It was developed by Mozilla Foundation and Mozilla Corporation. This program provides the HTTP API described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox. It translates calls into the Firefox remote protocol by acting as a proxy between the local- and remote ends. More on official website. It is used in Selenium3 scripts to control the applications over Gecko browsers like Firefox. Here we will the steps to install Geckodriver in Linux.

How to Install Geckodriver for Selenium in Linux

How to Install Geckodriver for Selenium in Linux

Also Read: How to Install ReactJS on Ubuntu 20.04 LTS (Focal Fossa)

Step 1: Prerequisites

a) You should have a running Linux Server.

b) You should have sudo or root access to run privileged commands.

c) You should have any file transfer utility like wget or curl to download Geckodriver.

 

Step 2: Download Geckodriver

You can download the latest Geckodriver from GitHub using any of the file transfer utility like wget or curl. At the time of writing this article, 0.32.0 is the latest released version which we are downloading using wget utility as shown below.

cyberithub@ubuntu:~$ wget https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux64.tar.gz
--2022-10-21 17:58:30-- https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux64.tar.gz
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/25354393/8e066757-fe10-45aa-b9a6-4b5660ff3abc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221021%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221021T122831Z&X-Amz-Expires=300&X-Amz-Signature=6726f16d765997cef4fd6582ec1090a1ab549801453f751de1e51683ebf1d446&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=25354393&response-content-disposition=attachment%3B%20filename%3Dgeckodriver-v0.32.0-linux64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2022-10-21 17:58:31-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/25354393/8e066757-fe10-45aa-b9a6-4b5660ff3abc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221021%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221021T122831Z&X-Amz-Expires=300&X-Amz-Signature=6726f16d765997cef4fd6582ec1090a1ab549801453f751de1e51683ebf1d446&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=25354393&response-content-disposition=attachment%3B%20filename%3Dgeckodriver-v0.32.0-linux64.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.111.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2991185 (2.9M) [application/octet-stream]
Saving to: ‘geckodriver-v0.32.0-linux64.tar.gz’

geckodriver-v0.32.0-linux64.tar.gz 100%[============================================================================>] 2.85M 6.86MB/s in 0.4s

2022-10-21 17:58:32 (6.86 MB/s) - ‘geckodriver-v0.32.0-linux64.tar.gz’ saved [2991185/2991185]

 

Step 3: Install Geckodriver

Next step is to extract the file in a directory from where you want to run the geckodriver tool. In our case, we are extracting it under /usr/local/bin directory using sudo tar -xzvf geckodriver-v0.32.0-linux64.tar.gz -C /usr/local/bin command as shown below.

cyberithub@ubuntu:~$ sudo tar -xzvf geckodriver-v0.32.0-linux64.tar.gz -C /usr/local/bin
geckodriver

 

Step 4: Provide Execute Permission

Next, you need to provide execute permission using chmod +x /usr/local/bin/geckodriver command to make it executable as shown below.

cyberithub@ubuntu:~$ chmod +x /usr/local/bin/geckodriver

 

Step 5: Export PATH (Optional)

If you have extracted Geckodriver to a location which is not visible under PATH environment variable then you need to export the path using below export command.

export PATH=$PATH:/extracted_file_path/

 

Step 6: Check Version

After successful installation, you can test it by running geckodriver -V command as shown below.

cyberithub@ubuntu:~$ geckodriver -V
geckodriver 0.32.0 (4563dd583110 2022-10-13 09:22 +0000)

The source code of this program is available from
testing/geckodriver in https://hg.mozilla.org/mozilla-central.

This program is subject to the terms of the Mozilla Public License 2.0.
You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.

 

Step 7: Start Geckodriver

You can start the web browser engine by simply running geckodriver on the terminal as shown below. By default, geckodriver would listen on Port 4444.

cyberithub@ubuntu:~$ geckodriver
1666355812817 geckodriver INFO Listening on 127.0.0.1:4444

You can also change the Port number by passing the port number as an argument as shown below.

cyberithub@ubuntu:~$ geckodriver --port=5665
1666355914521 geckodriver INFO Listening on 127.0.0.1:5665

 

Step 8: Check all the Available Options

You can check all the options available with geckodriver utility using geckodriver -h command as shown below.

cyberithub@ubuntu:~$ geckodriver -h
geckodriver 0.32.0 (4563dd583110 2022-10-13 09:22 +0000)
WebDriver implementation for Firefox

USAGE:
geckodriver [OPTIONS]

OPTIONS:
     --allow-hosts <ALLOW_HOSTS>...     List of hostnames to allow. By default the value of --host is allowed, and in addition if that's a well known
                                        local address, other variations on well known local addresses are allowed. If --allow-hosts is provided only
                                        exactly those hosts are allowed.
    --allow-origins <ALLOW_ORIGINS>...  List of request origins to allow. These must be formatted as scheme://host:port. By default any request with
                                        an origin header is rejected. If --allow-origins is provided then only exactly those origins are allowed.
    --android-storage <ANDROID_STORAGE> Selects storage location to be used for test data (deprecated). [possible values: auto, app, internal, sdcard]
-b, --binary <BINARY>                   Path to the Firefox binary
    --connect-existing                  Connect to an existing Firefox instance
-h, --help                              Prints this message
    --host <HOST>                       Host IP to use for WebDriver server [default: 127.0.0.1]
    --jsdebugger                        Attach browser toolbox debugger for Firefox
    --log <LEVEL>                       Set Gecko log level [possible values: fatal, error, warn, info, config, debug, trace]
    --marionette-host <HOST>            Host to use to connect to Gecko [default: 127.0.0.1]
    --marionette-port <PORT>            Port to use to connect to Gecko [default: system-allocated port]
-p, --port <PORT>                       Port to use for WebDriver server [default: 4444]
    --profile-root <PROFILE_ROOT>       Directory in which to create profiles. Defaults to the system temporary directory.
-v                                      Log level verbosity (-v for debug and -vv for trace level)
-V, --version                           Prints version and copying information
    --websocket-port <PORT>             Port to use to connect to WebDriver BiDi [default: 9222]

Leave a Comment