Encountering difficulties with obtaining the most recent geckodriver (0.21.0) and Selenium (3.13.0) to access a web page post launching the Tor Browser Bundle raised some concerns for me. It appears there might be compatibility issues between the older Firefox version utilized by Tor and the geckodriver, though this remains uncertain.
If you aim to utilize selenium-webdriver within the Tor network, consider implementing the following:
const webdriver = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
var options = new firefox.Options();
options.setPreference('network.proxy.type', 1) // manual proxy config
.setPreference('network.proxy.socks', '127.0.0.1')
.setPreference('network.proxy.socks_port', 9050)
.setPreference('network.proxy.socks_remote_dns', true) // resolve DNS over Tor
.setPreference('web proxy.socks_version', 5)
let driver = new webdriver.Builder()
.forBrowser('firefox')
.setFirefoxOptions(options)
.build();
driver.get('https://example.com/')
You will need to operate Tor using the expert bundle or opt to install and run it directly.
In an attempt to automate Tor Browser's functionality, I experimented with the following code snippet. Although it initiated all components correctly, the browser failed to navigate to the specified webpage.
const webdriver = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
var options = new firefox.Options();
options.setBinary('/home/me/Desktop/tor-browser_en-US/Browser/start-tor-browser');
options.addArguments('--detach');
(async function run() {
let driver = await new webdriver.Builder()
.forBrowser('firefox')
.setFirefoxOptions(options)
.build();
await driver.get('https://example.com/')
})();
To stress once more, the second example presented here did not yield the desired outcome. While tested on Mint 18 and Tor Browser 7.5.6 (FF ESR 52.9.0), Tor launches successfully along with the browser yet fails to navigate to any web pages.