简体   繁体   中英

Why is ChromeDriver working in Debug mode but not on release?

So I have this c# console app that I'm creating.

It uses Selenium ChromeDriver to create WordPress menus. It's working perfectly on debug mode.

Now I release it and when I install the app, run it, it's giving me this error:

The chromedriver.exe file does not exist in the current t directory or in a directory on the PATH environment variable.

This is where I believe I'm getting this error:

ChromeOptions options = new ChromeOptions();
options.AddArgument("start-maximized");
driver = new ChromeDriver(options);

I've searched all over the internet but nothing seems to work, I think it's something that has to do with Publishing in Visual Studio.

将 chromedriver.exe 从 Debug 文件夹复制到 Release 文件夹。

Presuming you have installed the NuGet package Selenium.WebDriver.ChromeDriver . You will find the latest chrome driver in \\Selenium.WebDriver.ChromeDriver\\driver\\win32\\chromedriver.exe select the correct version based on system.

Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".

This question should help

Selenium WebDriver.ChromeDriver Nuget package installed, but not working for MSTest

From the project owner github page:

"chromedriver(.exe) isn't included in published files on default configuration. This behavior is by design."

If you want to include "chromedriver(.exe)" into published files, please define "_PUBLISH_CHROMEDRIVER" compilation symbol (Under Project > Properties > Build)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM