In this guide you will see how to install Selenium on your Ubuntu 22.04 enviroment. That’s the best tutorial I found.
1. Login on your Ubuntu server as sudo and Upgrade all packages:
The first move, as always when you play with a linux enviroment is to update and upgrade all packages.
ssh root@yourserver
insert password
#
sudo apt update && upgrade -y
2. Download the latest Chromedriver and install:
Now you need to download you browser file, in this tutorial, and in the one I love https://github.com/password123456/setup-selenium-with-chrome-driver-on-ubuntu_debian
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt-get install -y ./google-chrome-stable_current_amd64.deb
3. Check the Installation:
# google-chrome --version
Google Chrome 123.0.6312.86
4. Install Selenium and Webdriver-manager with pip:
# pip3 install selenium
# pip3 install webdriver-manager
or simply
pip3 install selenium webdriver-manager
Finally: Create Your test File:
# vim peopleasks_selenium.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://www.peopleasks.com/how-to-install-python-selenium-ubuntu-22-04/")
print(driver.title)
driver.close()
In the next tutorials I’ll show you how to cron Selenium scripts