Open tor browser with selenium

后端 未结 10 1118
长发绾君心
长发绾君心 2020-12-02 09:15

Is it possible to make selenium use the TOR browser? Does anyone have any code they could copy-paste?

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 10:05

    System.setProperty("webdriver.firefox.marionette", "D:\\Lib\\geckodriver.exe");
            String torPath = "C:\\Users\\HP\\Desktop\\Tor Browser\\Browser\\firefox.exe";
            String profilePath = "C:\\Users\\HP\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default";
    
            File torProfileDir = new File(profilePath);
            FirefoxBinary binary = new FirefoxBinary(new File(torPath));
            FirefoxProfile torProfile = new FirefoxProfile(torProfileDir);
    
            FirefoxOptions options = new FirefoxOptions();
            options.setBinary(binary);
            options.setProfile(torProfile);
            options.setCapability(FirefoxOptions.FIREFOX_OPTIONS,options);
            WebDriver driver = new FirefoxDriver(options);
    

提交回复
热议问题