Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法在SeleniumWeb驱动程序-C中启动Chrome驱动程序#_C#_Selenium - Fatal编程技术网

C# 无法在SeleniumWeb驱动程序-C中启动Chrome驱动程序#

C# 无法在SeleniumWeb驱动程序-C中启动Chrome驱动程序#,c#,selenium,C#,Selenium,我很抱歉问这个问题。我已经尝试在这里检查解决方案&通过其他来源。但是,我找不到解决办法 我也在YouTube上看过一些视频。我的代码看起来不错。但是在我的电脑上运行V/Studio中的代码时会出错 这可能是由于缺少程序集引用造成的吗 代码如下: using System; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; namespace Chrome_Driver_Launch { class Program {

我很抱歉问这个问题。我已经尝试在这里检查解决方案&通过其他来源。但是,我找不到解决办法

我也在YouTube上看过一些视频。我的代码看起来不错。但是在我的电脑上运行V/Studio中的代码时会出错

这可能是由于缺少程序集引用造成的吗

代码如下:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace Chrome_Driver_Launch
{
    class Program
    {
        static void Main(string[] args)
        {
            var driver = new ChromeDriver();
            driver.navigate().GotoUrl("http://google.com");

        }
    }
}
下面是错误:

CS0246找不到类型或命名空间名称“OpenQA”(是否缺少using指令或程序集引用?)

我还尝试从V/Studio打开Firefox、MicrosoftInternetExplorer、MicrosoftEdge和Opera,但无法打开它们。我想这可能是因为缺少装配


谢谢。

您缺少对Selenium Webdriver的引用。右键单击项目Chrome\u驱动程序\u启动,然后单击“管理NuGet软件包”。在打开的选项卡中,单击浏览选项卡并搜索Selenium。安装Webdriver包。如果您已经拥有该软件包,则需要右键单击项目并单击“添加引用”,然后添加引用。

感谢您的帮助

我下载了浏览器。这修正了错误。我有两台笔记本电脑,我记得我没有安装浏览器

已安装,错误消失


再次感谢

此外,我还尝试从该网站下载ChromeDriver:我选择了:ChromeDriver_win32.zip我从下载了版本10586,但无法在V/Studio中添加绑定的相关引用。非常感谢,我欠你一个人情,伙计。。谢谢这似乎奏效了。但是,在运行代码时,我得到了一个错误:“WebDriver.dll中发生了类型为'System.invalidoOperationException'的未处理异常附加信息:未知错误:找不到Chrome二进制文件(驱动程序信息:chromedriver=XXXXXXX)非常感谢。您需要从这里下载chromedriver:然后您需要像下面的回答中那样设置它的路径:基本上只需这样做
System.setProperty(“webdriver.chrome.driver”,“/path/to/chromedriver”);
在您的
新chromedriver()语句之前