Home » Software Testing » Automation Testing » Selenium WebDriver Tutorial » How to Run Selenium Scripts In Tor Browser?

How to Run Selenium Scripts In Tor Browser?

What is Tor?

Tor is also known as the Tor Project which is handled by non-profit organization That handles research on the anonymity and privacy of anyone browsing online. Tor project is designed to prevent government agencies, any company or group of the organization to track the location of the user as well as the browsing habits of the end-user. This project directs all your traffic through thousands of worldwide volunteer overlay networks which consists of more than 7 thousands of relay to conceal the user identity and location from anyone who is performing network surveillance or network analysis.

Using Tor Browser is a medium to take benefits of the Tor Project. These browsers are equally available for desktop, laptop and mobile devices. So Anyone who cares about censorship and privacy could install tor browser on their devices and can save themselves from tracking or surveillance.


What are the benefits of Using Tor Browser?

There are many benefits of using Tor Browser. Here is the list of some of these benefits.

1- Blocks Tracking: Tor Browser isolates each website you visit so third-party trackers and ads can’t follow you. Any cookies automatically clear when you’re done browsing. So will your browsing history.

2- Defense against Surveillance: Tor Browser prevents someone watching your connection from knowing what websites you visit. All anyone monitoring your browsing habits can see is that you’re using Tor.

3- Resist Fingerprinting: Tor Browser aims to make all users look the same, making it difficult for you to be fingerprinted based on your browser and device information.

4- Multi-Layered Encryption: Your traffic is relayed and encrypted three times as it passes over the Tor network. The network is comprised of thousands of volunteer-run servers known as Tor relays.

5- Browse Freely: You can access sites those are blocked in your home network. This provides freedom to access any blocked site even in country like China and many more where government keep track of your every single site visit and activities

How to Run Tor Browser Through Selenium WebDriver?

We have seen in one of the post, how to run brave browser using Selenium WebDriver.. In this post we are going to talk about Tor browser handling through Selenium WebDriver.


1- Find Path of Tor browser binary. Tor browser is Firefox in its core. So if you are not using WebDriver Manager in that case you need to add gecko driver in System path.
In Windows Path would
C:\Users\<user-name>\Desktop\Tor Browser\Browser\firefox.exe

2- Find path of its profile
In Windows Path would be
C:\Users\<user-name>\Desktop\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default

3- Understanding of WebDriver manager to manage its binary driver.

Steps to Run Script In Tor Browser

  1. Since Tor Browser is based on Firefox Browser. So we need to download geckodriver.exe from its official website as per you machine’s operating system and extract it and provide the path in next step.
  2. Set System path
    System.setProperty("webdriver.gecko.driver","<Path On Your Machine>/geckodriver.exe" );  
    in place of Second Step you can use WebDriver manager to handle binary version dynamically.
  3. Now we need to Add Binary and Profile in FirefoxOptions

So let’s take one example.
1- We Would be Launching Tor Browser
2- We would be Opening “https://abodeqa.com”
3- We would be clicking on menu.
4- We Would be closing the Tor Browser.

But Before Launching the Tor Browser, Open Tor Browser Manually On you machine and select Auto-Connect Checkbox and establish a connection through Network. This is hack solution which few day back someone has asked me on a mail. For better solution, Might be I will be updating this code in future.

Hope this will help you to open Tor Browser through Selenium WebDriver.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Scroll to Top