title: Python Selenium with Tor Browser (Ubuntu)
body: <p>I try to open a Tor Browser using Selenium on Ubuntu 18. I have tried lots of examples but with no success.</p>
  
  <pre><code>proxyIP = "127.0.0.1"
  proxyPort = "9050"
  profileTor = '/etc/tor/' # torrc
  binary = os.path.expanduser("~/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/firefox")
  
  firefox_binary = FirefoxBinary(binary)
  firefox_profile = FirefoxProfile(profileTor)
  proxy_address = "127.0.0.1:9050"
  proxy = Proxy({
  'proxyType': ProxyType.MANUAL,
  'httpProxy': proxy_address,
   })
  driver = webdriver.Firefox(firefox_binary = firefox_binary,firefox_profile=firefox_profile, proxy = proxy)
  </code></pre>
  
  <p>A blank Tor Browser window opens but after a while I get an error as:</p>
  
  <pre><code>selenium.common.exceptions.WebDriverException: Message: connection refused.
  </code></pre>
  
  <p>I have also tried an alternative to firefox binary the: </p>
  
  <blockquote>
    <p>start-tor-browser</p>
  </blockquote>
  
  <p>which opens a working Tor Browser and showing some index. 
  The script however stops and I cannot visit another page using Selenium unless I do it manually.</p>
  
  <p>I have also tried the:</p>
  
  <blockquote>
    <p>profile.default</p>
  </blockquote>
  
  <p>as some examples suggest but I get an error:</p>
  
  <blockquote>
    <p>Unable to start Tor. The torrc file is missing and could not be created.</p>
  </blockquote>