close

How to set up a Selenium Python environment for Firefox

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to set up a Selenium Python environment for Firefox in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to set up a Selenium Python environment for Firefox?

  1. How to set up a Selenium Python environment for Firefox?

    The testing machine should have Selenium v. 3.0.2, Firefox v. 51.0.1 (latest version) and geckodriver v. 0.14. If you are using Linux, please do the following steps:

  2. set up a Selenium Python environment for Firefox

    The testing machine should have Selenium v. 3.0.2, Firefox v. 51.0.1 (latest version) and geckodriver v. 0.14. If you are using Linux, please do the following steps:

Method 1

The testing machine should have Selenium v. 3.0.2, Firefox v. 51.0.1 (latest version) and geckodriver v. 0.14. If you are using Linux, please do the following steps:

[Look up the latest release on GitHub (or from the API) and replace the wget link with that. Downloading and installing an outdating release may result in “buggy” behaviour.]

apt-get update
apt-get install firefox
pip3 install selenium==3.0.2
wget https://github.com/mozilla/geckodriver/releases/download/vX.XX.0/geckodriver-vX.XX.0-linuxXX.tar.gz -O /tmp/geckodriver.tar.gz \
  && tar -C /opt -xzf /tmp/geckodriver.tar.gz \
  && chmod 755 /opt/geckodriver \
  && ln -fs /opt/geckodriver /usr/bin/geckodriver \
  && ln -fs /opt/geckodriver /usr/local/bin/geckodriver

Select the version for your operating system from the available compressed pre-built binaries.

Here is an example to run:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://google.com')
print(driver.title)
driver.quit()

Method 2

As far as I understand, you want to develop in Python, using the Selenium library and work with the Firefox webdriver.

  1. Install Python (Python 3 already contains pip)
  2. Install Selenium (pip install selenium or some IDEs like PyCharm propose to install libraries, just import Selenium)
  3. Download Mozilla webdriver
  4. Enjoy!

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read