Install WebDriver Chrome or Firefox for Selenium for automated testing web application

 Chrome

  python3 pip3 install selenium
 
 
from selenium import webdriver 
from selenium.webdriver.chrome.service 
import Service 
s = Service('path_to_driver') 
driver = webdriver.Chrome(service=s)

 

Firefox


Installation for automated testing


sudo apt-get update


apt-get install -y unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4

apt-get install firefox

Pip install selenium

Sometimes you can get some exceptions

Selenium “Unable to find a matching set of capabilities” despite driver being in /usr/local/bin

Or

selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities




Updating Firefox and Selenium solved it for me. I don't pretend to have an explanation for the root cause however.


Updated Firefox 48 → 53


Updated to Selenium 3.4.1




https://pypi.org/project/selenium/

https://github.com/mozilla/geckodriver/releases



Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line


Firefox browser has installed?


apt-get install firefox


Script example for chrome WebDriver automated installation on Ubuntu


#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/

# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c

# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver

# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception

# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal

# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04

# Versions

CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
SELENIUM_STANDALONE_VERSION=3.4.0
SELENIUM_SUBDIR=$(echo "$SELENIUM_STANDALONE_VERSION" | cut -d"." -f-2)


Remove existing downloads and binaries so we can start from scratch.

sudo apt-get remove google-chrome-stable
rm ~/selenium-server-standalone-*.jar
rm ~/chromedriver_linux64.zip
sudo rm /usr/local/bin/chromedriver
sudo rm /usr/local/bin/selenium-server-standalone.jar
 

Install dependencies


sudo apt-get update
sudo apt-get install -y unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4


Install Chrome


sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
sudo echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
sudo apt-get -y update
sudo apt-get -y install google-chrome-stable


Install ChromeDriver

wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/

unzip ~/chromedriver_linux64.zip -d ~/

rm ~/chromedriver_linux64.zip

sudo mv -f ~/chromedriver /usr/local/bin/chromedriver

sudo chown root:root /usr/local/bin/chromedriver

sudo chmod 0755 /usr/local/bin/chromedriver

# Install Selenium.

wget -N http://selenium-release.storage.googleapis.com/$SELENIUM_SUBDIR/selenium-server-standalone-$SELENIUM_STANDALONE_VERSION.jar -P ~/

sudo mv -f ~/selenium-server-standalone-$SELENIUM_STANDALONE_VERSION.jar /usr/local/bin/selenium-server-standalone.jar

sudo chown root:root /usr/local/bin/selenium-server-standalone.jar

sudo chmod 0755 /usr/local/bin/selenium-server-standalone.jar








Comments