Selenium Webdriver on Headless Ubuntu



Run our sample code and develop your own scripts:

  • 1  Connect to the terminal via SSH and log into user 'ubuntu'. See here how.
  • 2a  Python 2

    Navigate into /home/ubuntu/python2 directory by
    cd /home/ubuntu/python2
    Run the sample code for Chrome by
    python sample-chrome.py
    Run the sample code for Firefox by
    python sample-firefox.py
    After a successful run you see:


    You can find taken screenshot by
    ls
    Edit files by
    sudo nano sample-chrome.py
    or deploy your scripts with a SCP tool.

    Run changed scripts again by
    python sample-chrome.py
  • 2b  Python 3

    Navigate into /home/ubuntu/python3 directory by
    cd /home/ubuntu/python3
    Run the sample code for Chrome by
    python3 sample-chrome.py
    Run the sample code for Firefox by
    python3 sample-firefox.py
    After a successful run you see:


    You can find taken screenshot by
    ls
    Edit files by
    sudo nano sample-firefox.py
    or deploy your scripts with a SCP tool.

    Run changed scripts again by
    python3 sample-firefox.py
  • 2c  Java

    Navigate into /home/ubuntu/java directory by
    cd /home/ubuntu/java
    Run the sample code for Chrome by
    java samplechrome
    Run the sample code for Firefox by
    java samplefirefox
    After a successful run you see:


    You can find taken screenshot by
    ls
    Edit files by
    sudo nano samplechrome.java
    or deploy your scripts with a SCP tool.

    Compile your changed scripts by
    javac samplechrome.java
    Run changed and compiled scripts by
    java samplechrome


  • 2d  JavaScript

    Navigate into /home/ubuntu/nodejs directory by
    cd /home/ubuntu/nodejs
    Run the sample code for Chrome by
    nodejs chrome-sample.js
    Run the sample code for Firefox by
    nodejs firefox-sample.js
    After a successful run you see:


    You can find taken screenshot by
    ls
    Edit files by
    sudo nano chrome-sample.js
    or deploy your scripts with a SCP tool.

    Run changed scripts by
    nodejs chrome-sample.js



Run scripts in the background while closing SSH window:

  • 1  Connect to the terminal via SSH and log into user 'ubuntu'. See here how.
  • 2  Start a new tmux session by
    tmux

  • 3  Start the script you want to run
  • 4  Leave the tmux session by pressing the keys CTRL+b and then d. You can now close the SSH session, the script will continue inside tmux
  • 5  Resume a tmux session by
    tmux attach