Selenium with Tor Browser on Ubuntu 18.04 with GUI



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.
  • 2  Open Tor Browser

    First we need to open the Tor browser so it can establish a connection to the tor network. Open directory Desktop -> SeleniumWithTor -> tor-browser_en-US, double-click on Tor Browser icon. Wait for the browser to start. The window must remain open in the background while proceeding with further steps.

  • 3  Run scripts with Python 3

    Open a terminal window and navigate into /home/guiuser/Desktop/SeleniumWithTor directory by
    cd /home/guiuser/Desktop/SeleniumWithTor

    Run the script by
    python3 sample-tor.py


    If everything went fine, you will see the following screen.


    To edit the script right click on it and open it with the text editor sublime text.


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 Unset an environment variable as workaround for an incompatibility between vnc and dbus
    unset DBUS_SESSION_BUS_ADDRESS
  • 4 Kill the VNC Server by
    vncserver -kill :1
  • 5 Start the VNC Server in X/Y window size by
    vncserver -geometry 1500x800