2017-06-16 70 views
2

我有此代码。我把chromedriver.exe在我的解决方案文件夹仓>>调试硒铬合金驱动程序在发布应用程序后停止工作

ChromeOptions options = new ChromeOptions(); 
options.AddArgument("--disable-notifications"); 

IWebDriver driver = new ChromeDriver(options); 
driver.Manage().Window.Maximize(); 

driver.Url = url; 

当我调试应用程序它的工作原理确定,但在发布后它抛出一个异常

enter image description here

我能做些什么?这是简单的控制台应用程序

回答

1

你应该尝试更新的ChromeDriver和Selenium版本。我刚刚检查了Selenium.WebDriver 3.4.0和Selenium.WebDriver.ChromeDriver 2.30.0.1

Starting ChromeDriver 2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41) on port 2935 
Only local connections are allowed. 
Press any key to continue . . . 

它工作正常的调试和发布版本的代码。

+0

你已经使用nuget安装了chrome驱动程序? – gsiradze

+0

发布应用程序后,它会抛出该错误:未处理的异常:OpenQA.Selenium.DriverServiceNotFoundException:chromedriver.exe文件不存在于当前目录或PATH环境变量的目录中。 – gsiradze

+1

是的,当然。这里是页面:[NuGet包 - Selenium WebDriver ChromeDriver](https://github.com/jsakamoto/nupkg-selenium-webdriver-chromedriver/)。然后,我将包文件夹**中的文件'chromedriver.exe'作为链接**添加到项目中,并将文件的属性设置为“Copy if newer”,从而在构建时自动将驱动程序复制到您的箱中。 –

相关问题