簡體   English   中英

更多使用c#的tor實例

[英]More the one instance of tor with c#

我正在嘗試使用c#打開多個具有不同身份的Tor瀏覽器實例。

瀏覽器之一可以正常打開:

在此處輸入圖片說明

但是,當代碼第二次打開時,我得到的瀏覽器為空:

在此處輸入圖片說明

這是我的C#代碼:

IWebDriver browser;

FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.proxy.type", 1);
profile.SetPreference("network.proxy.socks", "127.0.0.1");
profile.SetPreference("network.proxy.socks_port", 9150);
browser =  new FirefoxDriver(profile);
//    browser.Quit();

//Firefox's proxy driver executable is in a folder already
//  on the host system's PATH environment variable.
browser.Navigate().GoToUrl("http://dnsleaktest.com");
//IWebElement header = browser.FindElement(By.Id(“site - header"));

//Assert.True(header.Displayed);
// browser.Close();

Thread.Sleep(10000);
IWebDriver browser2;

FirefoxProfile profile2 = new FirefoxProfile();
profile2.SetPreference("network.proxy.type", 1);
profile2.SetPreference("network.proxy.socks", "127.0.0.1");
profile2.SetPreference("network.proxy.socks_port", 9152);
browser2 = new FirefoxDriver(profile2);
//    browser.Quit();

//Firefox's proxy driver executable is in a folder already
//  on the host system's PATH environment variable.
browser.Navigate().GoToUrl("http://dnsleaktest.com");
//IWebElement header = browser.FindElement(By.Id(“site - header"));

//Assert.True(header.Displayed);
// browser.Close();

請根據需要更正我的英語

的NuGet:

  • NUnit3TestAdapter
  • 列出它Selenium.WebDriverem

更改此行:

        //Firefox's proxy driver executable is in a folder already
        //  on the host system's PATH environment variable.
        browser.Navigate().GoToUrl("http://dnsleaktest.com");
        //IWebElement header = browser.FindElement(By.Id(“site - header"));

對此:

        //Firefox's proxy driver executable is in a folder already
        //  on the host system's PATH environment variable.
        browser2.Navigate().GoToUrl("http://dnsleaktest.com");
        //IWebElement header = browser.FindElement(By.Id(“site - header"));

當您需要瀏覽第二個瀏覽器對象時,您正在瀏覽第一個瀏覽器對象。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM