

Prior to running this above code, you may have to export the environment variable TBB_PATH as follows, otherwise, you will get an error stating that TBB_PATH is undefined:Įxport TBB_PATH=/path/to/tbb/tor-browser_en-US/ With TorBrowserDriver("/path/to/tbb/tor-browser_en-US/") as driver: This the code from that repository that worked for me:įrom tbselenium.tbdriver import TorBrowserDriver I tried tor-browser-selenium link, which worked like a charm. After spending a lot of time trying to make Tor work with Selenium on Ubuntu, I gave up and concluded that it might be easier to use a different tool specialized for Tor. Test that TorBrowser works by double-clicking the TorBrowser icon in the folder. On Ubuntu, you can just leave the unzipped folder where it is. Leave the TorBrowser running and run the following code.įrom _binary import FirefoxBinaryīinary = FirefoxBinary("/Applications/TorBrowser.app/Contents/MacOS/firefox")ĭriver = webdriver.Firefox(firefox_binary= binary)

MacOS will prompt you to move the contents to the Applications folder. First, install the Tor Browser by downloading the appropriate package from here.

I was able to run the Tor Browser on MacOS using Selenium.
