Installing Selenium and Chromedriver on Ubuntu

Source: Internet
Author: User
Tags virtual environment virtualenv

I recently got Selenium, Google Chrome, and Chromedriver installed and working on a Digitalocean instance running 64-bit U Buntu 14.04. Here's how:

First, install Google Chrome for Debian/ubuntu:

sudo apt-get install libxss1 libappindicator1 libindicator7wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.debsudo dpkg -i google-chrome*.debsudo apt-get install -f

Now, let's install so xvfb we can run Chrome headlessly:

sudo apt-get install xvfb

Install chromedriver:1

sudo apt-get install unzipwget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zipunzip chromedriver_linux64.zipchmod +x chromedriversudo mv -f chromedriver /usr/local/share/chromedriversudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriversudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver

Install some Python dependencies for Selenium:

sudo apt-get install python-pip## (Optional) Create and enter a virtual environment:# sudo apt-get install python-virtualenv# virtualenv env# source env/bin/activatepip install pyvirtualdisplay selenium

Now, we can do stuff like this with Selenium in Python:

FromPyvirtualdisplayImportDisplayFromSeleniumImportwebdriverdisplay = display (visible=0size=< Span class= "P" > (800600 Display. Start () driver = webdriver.chrome () driver. Get ( ' http://christopher.su ' ) print driver. Title                  
Footnotes

1:you can find all the chromedriver releases here. If you ' re using a 32-bit system or a non-linux OS, the Chromedriver download used above won ' t work.

Installing Selenium and Chromedriver on Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.