• Home
  • Uncategorized
  • How To Install Google Chrome, Selenium & Chromedriver For AWS EC2 Instances

How To Install Google Chrome, Selenium & Chromedriver For AWS EC2 Instances

If you’re looking to use selenium and headless browsers on amazon web services (AWS) its essential that you install the relevant versions of selenium, ChromeDriver and Google Chrome to your EC2 instance. In this guide you’ll learn how to easily deploy and test a fully functional selenium python environment.

Install ChromeDriver

You will need to install ChromeDriver which allows you programmatic access to google chrome via the Webdriver API protocol.

Go to Google Chrome for Testing GitHub Downloads page: https://googlechromelabs.github.io/chrome-for-testing/

Choose your desired Channel. I am choosing the Stable channel.

Copy the URL for chromedriver binary according to your platform. Make sure its HTTP status is 200. I am choosing this URL for my Linux machine: https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip

cd /tmp/
wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
unzip chromedriver-linux64.zip
cd chromedriver-linux64
sudo mv chromedriver /usr/bin/chromedriver
chromedriver --version

If you get the fallowing error when running ‘chromedriver –version’ it indicates that the libnss3.so shared library file is missing or cannot be found on your system. libnss3.so is a part of the Network Security Services (NSS) library, which is used by various applications for SSL/TLS support.

To resolve this issue, you can try the following steps based on your operating system:

For Ubuntu/Debian-based systems:

  1. Update your package list: sudo apt-get update
  2. Install the libnss3 package: sudo apt-get install libnss3

For CentOS/RHEL-based systems:

  1. Update your package list: sudo yum update
  2. Install the nss package: sudo yum install nss

Once you’ve installed the required library, try running chromedriver --version again. If the issue persists, you may need to check if there are any other missing dependencies or if there are specific compatibility issues with your system. Additionally, make sure that your system is up-to-date with the latest updates and patches.

Install Chrome on Ubuntu, Debian, and Linux Mint

Open SSH terminal and use the following commands to install Google Chrome on Debian based Linux distributions, such as UbuntuDebianKali, and Linux Mint.

cd /tmp/
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 
sudo apt install ./google-chrome-stable_current_amd64.deb
google-chrome --version

Running a selinum test:

python3 filename.py

When i try to run the selenium test, I get this error:

The error message “ModuleNotFoundError: No module named ‘selenium'” indicates that Python cannot find the Selenium module in your current environment. To resolve this issue, you need to install the Selenium package.

You can install Selenium using a package manager like pip. Open a terminal or command prompt and run the following command: pip install selenium

Now I get following error:

Then I tried running: python3 -m pip install selenium

and got the following error:

The error “No module named pip” indicates that the pip tool is not installed or not available for your Python installation.

In some systems, the python3 installation may not include pip by default. You can install it separately. Here are some general steps:

For Debian/Ubuntu-based systems:

sudo apt update
sudo apt install python3-pip

After this now you need to install selenium module. Using: pip3 install selenium

ABOUT AUTHOR

CATEGORY

FOLLOW US