【问题标题】:Selenium WebDriver - No driver is working for meSelenium WebDriver - 没有驱动程序为我工作
【发布时间】:2012-07-12 16:31:28
【问题描述】:

我正在尝试运行 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:\Users\Vilem\AppData\Local\Google\Chrome\Application

火狐

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

我有什么遗漏吗?如果他们中的任何一个开始工作,我会很高兴。

谢谢

【问题讨论】:

  • 如果将驱动程序保存在与测试程序集相同的目录中会发生什么?这样您就不需要告诉 Selenium 去哪里查找,因为它的第一个调用端口是在与程序集相同的目录中查找,所以如果您将驱动程序保存在同一文件夹中会有什么不同吗?
  • 我也试过了,很遗憾没有改变。

标签: c# selenium webdriver


【解决方案1】:

我通过将 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();
    }
...

如果您还没有,可以从here 下载 .exe

【讨论】:

    【解决方案2】:

    无法在以下位置找到 Chrome 二进制文件:
    C:\Users\Vilem\AppData\Local\Google\Chrome\Application

    我认为您必须指定包括可执行文件在内的整个路径。像 C:\Users\Vilem\AppData\Local\Google\Chrome\Application\chrome.exe(只是猜测,目前无法访问Windows机器)

    火狐

    无法在 45000 毫秒内绑定到锁定端口 7054

    您不应该永久获得它。告诉您而不问很多问题的最快解决方案:重新启动(或注销-登录)。如果您在重新启动后仍然得到它,请查看有关它的问题并发布您自己的问题。

    【讨论】:

    • 我也尝试了包含“chrome.exe”的路径,结果相同。明天我会在我的工作电脑启动后再次尝试 Firefox,并通知你。
    • 重启后使用火狐驱动没有变化。
    【解决方案3】:

    您应该指定包含 .exe 的路径。因此,您的代码如下:

    options.BinaryLocation = @"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\chrome.exe";
    new InternetExplorerDriver(@"C:\Program Files (x86)\IEDriver\iexplore.exe", ieOptions);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-03
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 2014-03-27
      • 2015-05-21
      相关资源
      最近更新 更多