Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tsl0922/ab8d370a85653c4354ad to your computer and use it in GitHub Desktop.

Select an option

Save tsl0922/ab8d370a85653c4354ad to your computer and use it in GitHub Desktop.

Revisions

  1. tsl0922 revised this gist Aug 26, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions setup-headless-selenium-xvfb.sh
    Original file line number Diff line number Diff line change
    @@ -55,3 +55,7 @@ export DISPLAY=:99

    # Optionally, capture screenshots using the command:
    #xwd -root -display :99 | convert xwd:- screenshot.png

    # Optionally, start vnc server for xvfb:
    #sudo apt-get install x11vnc
    #x11vnc --listen 0.0.0.0 -rfbport 5900 -display :99 -forever
  2. @alonisser alonisser revised this gist Apr 22, 2014. 1 changed file with 13 additions and 9 deletions.
    22 changes: 13 additions & 9 deletions setup-headless-selenium-xvfb.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash
    #
    # Bash script to setup headless Selenium (uses Xvfb and Chrome)
    # (Tested on Ubuntu 12.04)
    # (Tested on Ubuntu 12.04) trying on ubuntu server 14.04

    # Add Google Chrome's repo to sources.list
    echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
    @@ -14,10 +14,14 @@ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-ke
    sudo apt-get update

    # Install Python, pip, Selenium:
    sudo apt-get -y install python python-pip
    sudo pip install selenium

    sudo apt-get -y install unzip
    #sudo apt-get -y install python python-pip
    #sudo pip install selenium
    different way to get chromedriver and selenium java jar:
    sudo apt-get -y install default-jre # if not installed yet
    sudo npm install protractor -g
    sudo webdriver-manager update
    sudo ln /usr/lib/node_modules/protractor/selenium/chromedriver /usr/bin/chromedriver
    #sudo apt-get -y install unzip
    # Download/Install chromedriver
    # (http://code.google.com/p/chromedriver/):
    #
    @@ -26,12 +30,12 @@ sudo apt-get -y install unzip
    #unzip chromedriver_linux32_2.1.zip
    #
    # For x86-64:
    wget -c http://chromedriver.googlecode.com/files/chromedriver_linux64_2.1.zip
    unzip chromedriver_linux64_2.1.zip
    #wget -c http://chromedriver.googlecode.com/files/chromedriver_linux64_2.1.zip
    #unzip chromedriver_linux64_2.1.zip
    # Neither creating symbolic link nor adding dir to $PATH worked for me
    # in a Vagrant VM. So, let's blatantly copy the binary:
    sudo cp ./chromedriver /usr/bin/
    sudo chmod ugo+rx /usr/bin/chromedriver
    #sudo cp ./chromedriver /usr/bin/
    #sudo chmod ugo+rx /usr/bin/chromedriver

    # Install Google Chrome:
    sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
  3. @amberj amberj created this gist Sep 25, 2013.
    53 changes: 53 additions & 0 deletions setup-headless-selenium-xvfb.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    #!/bin/bash
    #
    # Bash script to setup headless Selenium (uses Xvfb and Chrome)
    # (Tested on Ubuntu 12.04)

    # Add Google Chrome's repo to sources.list
    echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list

    # Install Google's public key used for signing packages (e.g. Chrome)
    # (Source: http://www.google.com/linuxrepositories/)
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

    # Update apt sources:
    sudo apt-get update

    # Install Python, pip, Selenium:
    sudo apt-get -y install python python-pip
    sudo pip install selenium

    sudo apt-get -y install unzip
    # Download/Install chromedriver
    # (http://code.google.com/p/chromedriver/):
    #
    # For x86:
    #wget -c http://chromedriver.googlecode.com/files/chromedriver_linux32_2.1.zip
    #unzip chromedriver_linux32_2.1.zip
    #
    # For x86-64:
    wget -c http://chromedriver.googlecode.com/files/chromedriver_linux64_2.1.zip
    unzip chromedriver_linux64_2.1.zip
    # Neither creating symbolic link nor adding dir to $PATH worked for me
    # in a Vagrant VM. So, let's blatantly copy the binary:
    sudo cp ./chromedriver /usr/bin/
    sudo chmod ugo+rx /usr/bin/chromedriver

    # Install Google Chrome:
    sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
    sudo apt-get -y install google-chrome-stable

    # Dependencies to make "headless" chrome/selenium work:
    sudo apt-get -y install xvfb gtk2-engines-pixbuf
    sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable

    # Optional but nifty: For capturing screenshots of Xvfb display:
    sudo apt-get -y install imagemagick x11-apps

    # Make sure that Xvfb starts everytime the box/vm is booted:
    echo "Starting X virtual framebuffer (Xvfb) in background..."
    Xvfb -ac :99 -screen 0 1280x1024x16 &
    export DISPLAY=:99

    # Optionally, capture screenshots using the command:
    #xwd -root -display :99 | convert xwd:- screenshot.png