Selenium Webdriver on Graphical Ubuntu



Run our sample code and develop your own scripts:

  • 1  Connect to the instance via RDP or VNC, log into user 'guiuser'. See here how.
  • 2a  Python 2

    Open a terminal window and navigate into /home/guiuser/Selenium/python2 directory by
    cd /home/guiuser/Selenium/python2
    Run the sample code for Chrome by
    python sample-chrome.py
    Run the sample code for Firefox by
    python sample-firefox.py
    You can watch how Chrome/Firefox execute the sample script. After a successful run you see:


    Open the directory Desktop -> Selenium -> python2 to see taken screenshots. Edit the script by right-click -> Open with Sublime Text. When you are done, save the file. Switch back to the Terminal window and run changed scripts again by
    python sample-firefox.py


  • 2b  Python 3

    Open a terminal window and navigate into /home/guiuser/Selenium/python3 directory by
    cd /home/guiuser/Selenium/python3
    Run the sample code for Chrome by
    python3 sample-chrome.py
    Run the sample code for Firefox by
    python3 sample-firefox.py
    You can watch how Chrome/Firefox execute the sample script. After a successful run you see:


    Open the directory Desktop -> Selenium -> python3 to see taken screenshots. Edit the script by right-click -> Open with Sublime Text. When you are done, save the file. Switch back to the Terminal window and run changed scripts again by
    python3 sample-chrome.py


  • 2c  Java

    Open Eclipse Java by opening directory Desktop -> eclipse -> java-2019 -> eclipse -> double-click on eclipse. Afterwards, click on the green 'Run' icon.


    When you make changes, save the file. By clicking on 'Run', the file gets compiled automatically before executing the script.
  • 2d  JavaScript

    Open a terminal window and navigate into /home/guiuser/Selenium/nodejs directory by
    cd /home/guiuser/Selenium/nodejs
    Run the sample code for Chrome by
    nodejs chrome-sample.js
    Run the sample code for Firefox by
    nodejs firefox-sample.js
    You can now watch the script executing:


    You can find taken screenshot in the above directory.
    Edit the script by right-click -> Open with Sublime Text. When you are done, save the file. Switch back to the Terminal window and run changed scripts again by
    nodejs chrome-sample.js



Manage VNC server:

  • 1  When you reboot your instance, you need to reboot VNC as well. Connect to the terminal via SSH and log into user 'ubuntu'. See here how.
  • 2  Switch to 'guiuser' by
    su guiuser

    The standard password for this user are the first 8 characters of your AWS instance ID.
  • 3 Kill the VNC Server by
    vncserver -kill :1
  • 3 Start the VNC Server in X/Y window size by
    vncserver -geometry 1500x800