Selenium WebDriver – 没有司机在为我工作
我正在努力让Selenium测试运行。 我正在使用C#。 我遇到的每个司机都遇到了问题。
铬
var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.BinaryLocation = @"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\"; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { ...
好像找到了chromedriver.exe,但它可以找到Chrome二进制文件。 在自动搜索失败后,我明确设置了chrome.exe的路径。 我甚至在最后尝试使用“chrome.exe”。 我总是得到相同的结果:
找不到Chrome二进制文件:
C:\用户\ Vilem \应用程序数据\本地\谷歌\镀铬\应用
火狐
new OpenQA.Selenium.Firefox.FirefoxDriver();
我也尝试了配置文件:
FirefoxProfile profile = new FirefoxProfile(@"E:\...\FirefoxProfile"); new OpenQA.Selenium.Firefox.FirefoxDriver();
我得到的错误:
无法在45000毫秒内绑定到锁定端口7054
IE
var ieOptions = new InternetExplorerOptions(); ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; new InternetExplorerDriver(@"C:\Program Files (x86)\IEDriver\", ieOptions);
带有驱动程序的文件夹也在PATH中设置。
我得到的错误:
No response from server for url http://localhost:6955/session
有什么我想念的吗? 如果他们中的任何一个工作,我会很高兴。
谢谢
我通过将chromeDriver和IE_driver的.exe放在项目/ bin /文件夹中来使Chrome和IE工作
防爆。
VisualStudio2010/Projects/ProjName/ProjName/bin/chromedriver.exe
然后在设置测试时我做了:
using OpenQA.Selenium.Chrome; ... private IWebDriver chrome; ... [SetUp] public void SetupTest() { chrome= new ChromeDriver(); baseURL = "url-goes-here"; verificationErrors = new StringBuilder(); } ...
如果你还没有,可以从这里下载.exe
铬
找不到Chrome二进制文件:
C:\用户\ Vilem \应用程序数据\本地\谷歌\镀铬\应用
我认为你必须指定包括可执行文件在内的整个路径。 像C:\Users\Vilem\AppData\Local\Google\Chrome\Application\chrome.exe
(只是猜测,目前无权访问Windows机器)
火狐
无法在45000毫秒内绑定到锁定端口7054
你不应该永久得到它。 最快的解决方案,告诉你没有回答很多问题:重启(或登出登录)。 如果您在重新启动后仍然可以获得该function,请查看有关它的问题并发布您自己的问题。
您应该指定包含.exe的路径。 所以,你的代码如下:
options.BinaryLocation = @"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\chrome.exe"; new InternetExplorerDriver(@"C:\Program Files (x86)\IEDriver\iexplore.exe", ieOptions);