![](/img/trans.png)
[英]Running Internet Explorer selenium web driver in private mode c#
[英]Selenium - Visual Studios- C# - All (chrome, firefox, and internet explorer) webdrivers unable to start driver service
我正在嘗試設置 Selenium 進行測試,但我的網絡驅動程序似乎都沒有工作。 我曾嘗試在項目文件夾中移動它們,而讓 Visual Studios 找到它們的唯一方法是使用 @"path" 語句。
真正的問題是……一旦 Visual Studio 找到 webdriver,操作就會超時,並且出現以下異常:
WebDriver.dll 中發生類型為“OpenQA.Selenium.WebDriverException”的未處理異常附加信息:無法在http://localhost:(每次更改的隨機端口號)上啟動驅動程序服務
我嘗試重新啟動計算機並讓系統管理員檢查防火牆和惡意軟件攔截器日志,但似乎都沒有幫助(或者他們不知道要查找的正確內容)。
我認為這是非常簡單的事情,我只是想念它......任何幫助將不勝感激。
這是我的代碼的副本:
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
namespace SeleniumWork
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new InternetExplorerDriver(@"C:\blahblahpathstring");
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Cheese");
query.Submit();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(d => d.Title.StartsWith("cheese", StringComparison.OrdinalIgnoreCase));
Console.WriteLine("Page title is: " + driver.Title);
}
}
}
這是我收到的調試輸出的副本:
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
我在我的工作機器上遇到了同樣的問題,但在我的個人機器上卻沒有。 我可以在兩者之間唯一的區別是我在家里使用VS 2015而在工作中使用VS 2017。
修復它的是我使用NuGet包管理器進行項目並下載了jbaranda的Selenium.Firefox.WebDriver,后者使用基於marionette的新驅動程序而不是gecko驅動程序。
安裝完成后,我可以啟動並運行firefox瀏覽器,無需任何額外的配置或選項:
IWebDriver driver = new FirefoxDriver();
driver.Url = "www.google.com";
而在此之前,它會引發“無法啟動驅動程序服務...”的例外情況。 其他瀏覽器有NuGet包,我建議您使用的是特定的一個,但唯一一個我沒有問題的是IE。 希望有所幫助
我遇到了同樣的問題,並且根本不知道如何修復它。 最后我發現防火牆阻止了流量回送。 安裝在機器上的防火牆是McAffe。
我所做的就是停止管理流量掃描的服務。
希望它會對你有所幫助。
我在IEDriverServer上一直都是這樣,很少在FireFox上。
當它在FireFox上發生時修復了兩次 - 第一次更新壁虎驅動程序,第二次重新啟動我的PC。 環境中的某些東西正在發生,也許驅動程序有時並沒有完全退出,所以新的實例化被阻止了?
嗨,解決了嗎,你能把解決方案的鏈接發給我嗎
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.