Skip to content
Abode QA
Abode QA

A Hub For Testing Minds…

  • Home
  • Video Tutorial
    • Selenium WebDriver
    • Spock Framework
    • Katalon Studio
    • Git Tutorial
    • SQL Tutorial
    • Geb & Spock
    • Groovy
  • Manual Testing
  • Selenium-WebDriver
  • Quiz
    • Selenium WebDriver Quiz
    • Software Testing Quiz | Software Testing Interview Preparation Question
  • Java Tutorial
  • Katalon
  • Fitnesse
  • Daily Bytes!!
Abode QA

A Hub For Testing Minds…

How to Run Selenium Scripts In Tor Browser?

Dwarika Dhish Mishra, March 8, 2022March 7, 2022

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.

Table Of Contents
  1. What is Tor?
  2. What are the benefits of Using Tor Browser?
  3. How to Run Tor Browser Through Selenium WebDriver?
    • Pre-condition
    • Steps to Run Script In Tor Browser
How-to-Run-Selenium-WebDriver-Scripts-In-Tor-Browser

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.

Trending
How AI is Revolutionizing Software Testing and Enhancing Quality

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.

Pre-condition

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" );  
    or
    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.

package webdriverExample;

import java.io.File;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import io.github.bonigarcia.wdm.WebDriverManager;

/**
 * @author Dwarika
 *
 */
public class TorBrowserInSelenium {

	public static void main(String[] args) throws IOException, InterruptedException {

		// Setting dynamically binary path of gecko driver executable in path
		WebDriverManager.firefoxdriver().setup();

		// Path of Tor Browser Binary
		String torBinaryPath = "C:\\Users\\dwari\\Desktop\\Tor Browser\\Browser\\firefox.exe";

		// Creating Object of FirefoxOptions
		FirefoxOptions options = new FirefoxOptions();

		// Creating FirefoxProfile by providing default Tor Profile.
		FirefoxProfile fb = new FirefoxProfile(new File(
				"C:\\Users\\dwari\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"));

		// Setting profile to FirefoxOptions.
		options.setProfile(fb);

		// Setting binary in Firefox Options.
		options.setBinary(torBinaryPath);

		// Creating driver.
		WebDriver driver;
		driver = new FirefoxDriver(options);

		// Maximizing Browser
		driver.manage().window().maximize();

		// Opening Aboceqa site
		driver.get("https://abodeqa.com");

		// Clicking on Manual Testing Menu
		driver.findElement(By.xpath("//*[@id=\"menu-item-2433\"]/a/span[2]")).click();

		// Closing browser instance.
		driver.quit();

	}
}

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

Popular Posts

  • How AI is Revolutionizing Software Testing and Enhancing Quality
  • Delete, Truncate and Drop Statement In SQL with Example
  • What are Web Services, Types And Its Advantages?
  • How to Connect Selenium To Existing Chrome Browser?

Share this:

  • Tweet
  • More
  • Pocket
  • Email
  • Reddit
  • Share on Tumblr
  • Print
  • WhatsApp

Related

Selenium WebDriver Tutorial How To Run Selenium Scripts In Tor Browser

Post navigation

Previous post
Next post

Leave a ReplyCancel reply

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

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,582 other subscribers
  • Top Mozilla Firefox Plugins For Better Productivity With Key Features!!
  • How To Run Selenium Tests In Brave Browser Using ChromeDriver?
  • Top Chrome Extensions For Better Productivity !!
  • Top Best Software Testing Trends to watch out in 2021
  • Top-Notch Mozilla Firefox Add-ons to Install
  • 10 Best FREE YouTube Video Downloader Apps For Year 2021.
  • WebDriverManager: New Way to handle driver binaries in Selenium
  • Requirement of Testing environment
  • How To Create S3 Bucket Command? | AWS CLI Commands
  • How To Use LS and CP command In AWS?

Top Posts & Pages

  • Reviews,Walkthrough And Inspection In Software Testing
    Reviews,Walkthrough And Inspection In Software Testing
  • How to Connect Selenium To Existing Chrome Browser?
    How to Connect Selenium To Existing Chrome Browser?
  • How to use Contains() and starts-with() function in Xpath
    How to use Contains() and starts-with() function in Xpath
  • 5 Commonly Asked Java String Question in Selenium Interview
    5 Commonly Asked Java String Question in Selenium Interview
  • Upload and Download file from FTP Server using Java FTP Client
    Upload and Download file from FTP Server using Java FTP Client
  • Arrays in Java and its implementation in WebDriver
    Arrays in Java and its implementation in WebDriver
  • SSH To Ubuntu Installed On VirtualBox | Putty To Ubuntu
    SSH To Ubuntu Installed On VirtualBox | Putty To Ubuntu
  • "You are using an unsupported command-line flag --ignore-certificate-errors. Stability and security will suffer." Handling in WebDriver using ChromeOptions()
    "You are using an unsupported command-line flag --ignore-certificate-errors. Stability and security will suffer." Handling in WebDriver using ChromeOptions()
  • assertTrue(message,condition) in Selenium WebDriver and it's implementation
    assertTrue(message,condition) in Selenium WebDriver and it's implementation
  • Test Cases To Test Software Updates Before Its Release
    Test Cases To Test Software Updates Before Its Release
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
©2023 Abode QA | WordPress Theme by SuperbThemes
 

Loading Comments...