What is Tor Browser?
Well, Tor browser is cool because it allows you to browse the web anonymously. If you take a look at your IP address in a Tor browser, you will notice that it's not the actual IP of your computer. In fact, your IP might come from a completely different country when you are using a Tor browser.
As a QA Automation Engineer, I like using Tor to see how my application handles different ip addresses. You can run a test on Tor and see how the web app handles a visitor from Australia, Germany, and any other random country. You can check the performance of your app against different locations and make sure that this is acceptable to your Product Owners or clients. Furthermore, journalists like to use this to stay anonymous on the web. Some people like to use this browser to just stay anonymous in general. And others even use this browser for bad things that occur on the Deep Web (tum dum dum...).
Whatever your need for using the Tor browser, I will teach you how to use Selenium Webdriver to automate that sucker. What you do with this knowledge is up to you.
Our Test Case
The goal for this test case is simple:
- Open Tor browser using Selenium Webdriver
- Go to this url www.qtptutorial.net/automation-practice
- Select the radio button that says, “I love HP UFT”
- Download the Tor browser here
- Pick the appropriate version based on your Operating System
- You will download an application called something like “torbrowser-install-5.0.4_en-US” that will take you through the installation process
- Afterwards, there will be a folder where you installed Tor that looks something like this
4. Next, download my sample VS application
If you’re not sure how to download a Github project, you can learn that here.
5. I took this folder and placed it inside of my ‘Drivers’ folder for my Visual Studio project. You should do the same thing and place the ‘Browser’ folder into the ‘Drivers’ folder of the code that you just downloaded from my Github. This looks like the image below.
6. Open up your Visual Studio and open the Tor.sln file that you just downloaded.
7. Open the UnitTest2.cs class that contains our unit test.
8. Look at the SetupTest() method. Inside, you will need to update the ‘torBinaryPath’ variable to point to the firefox.exe in your ‘Browser’ folder.
My code looks like this: var torBinaryPath = "C:\Source\Github\Tor\TorTest\Drivers\Browser\firefox.exe";
9. Yes, you will need to install Firefox if you do not have it. We use the proxy generated by Tor, but our test actually runs in Firefox. This is really awesome because you guys should be familiar with running automation tests on Firefox.
How to run a Webdriver test with Tor?
1. Go inside of the UnitTest2.cs file to run the unit test just like any other unit test in Visual Studio. If you’re not sure how to do that, take the Selenium course to learn.
2. When you are running the test, you will notice that the Tor browser is the first to load. However, your test actually runs in Firefox.
If you don’t believe that your ip has changed and want to double check, you can see your ip here before you run the test.
Next, pause the test in the middle, after getting the QTP Tutorial website.
Finally, go back to this website and notice how now you have a “different” ip. That’s because you’re browsing anonymously!
3. That’s all there is to it. Feel free to update the code for whatever purpose you want. Element identification can be done in Firefox without any issues.
Latest posts by Nikolay Advolodkin (see all)
- Best Online Resources to Learn Automation Testing - December 22, 2016
- Parallel Test Execution Using Selenium Webdriver - April 26, 2016
- Proper Black Box Test Case Design-part 2-Boundary Value Analysis - April 5, 2016