I get error when I try to run my test in Chrome :
当我尝试在Chrome中运行测试时出错:
Initialization method AutomationUsingSelenium.SmuladorChrome.MyTestInitialize threw exception. OpenQA.Selenium.DriverServiceNotFoundException: OpenQA.Selenium.DriverServiceNotFoundException
初始化方法AutomationUsingSelenium.SmuladorChrome.MyTestInitialize抛出异常。 OpenQA.Selenium.DriverServiceNotFoundException:OpenQA.Selenium.DriverServiceNotFoundException
What is the cause?
原因是什么?
4 个解决方案
#1
13
Finally I resolve my issue.
最后我解决了我的问题。
1) I copied chromedriver.exe in Chrom directory link, but you can put in any directory, I decided to put here.
1)我在Chrom目录链接中复制了chromedriver.exe,但是你可以放入任何目录,我决定放在这里。
2) I Initialized a new instance of the ChromeDriver class using the specified // path to the directory containing ChromeDriver.exe
2)我使用指定包含ChromeDriver.exe的目录的路径初始化了ChromeDriver类的新实例
My code:
我的代码:
IWebDriver drive = new ChromeDriver
("C:\\Documents and Settings\\...\\ApplicationData\\Google\\Chrome\\Application");
And it works just perfect. Thanks All.
它的工作原理非常完美。谢谢大家。
#2
5
Lets assume chromedriver.exe
is present in below path: G:\Selenium_Csharp\Jar\chromedriver_win32\chromedriver.exe
让我们假设chromedriver.exe出现在下面的路径:G:\ Selenium_Csharp \ Jar \ chromedriver_win32 \ chromedriver.exe
To execute your test in Chrome set the path to the directory/folder containing chromedriver.exe
without selecting chromedriver.exe
file name.
要在Chrome中执行测试,请设置包含chromedriver.exe的目录/文件夹的路径,而不选择chromedriver.exe文件名。
driver = new ChromeDriver("G:\\Selenium_Csharp\\Jar\\chromedriver_win32");
driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();
OR
要么
driver = new ChromeDriver(@"G:\Selenium_Csharp\\Jar\\chromedriver_win32");
driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();
#3
2
Install Selenium.Chrome.WebDriver
NuGet package to the project and you will not get the error again.
将Selenium.Chrome.WebDriver NuGet包安装到项目中,您将不会再次收到错误。
In Visual Studio, right click the Project, click Manage NuGet Packages... , Search for Selenium.Chrome.WebDriver and click install.
在Visual Studio中,右键单击“项目”,单击“管理NuGet包...”,“搜索Selenium.Chrome.WebDriver”,然后单击“安装”。
Enjoy Selenium.
享受Selenium。
#4
0
This is the error i see: OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
这是我看到的错误:OpenQA.Selenium.DriverServiceNotFoundException:chromedriver.exe文件不存在于当前目录或PATH环境变量的目录中。
I resolved this problem by specifying the 'testsettings' argument in the command to run the unit tests.
我通过在命令中指定'testsettings'参数来运行单元测试来解决这个问题。
E.g.
例如。
E:\Development\SampleProject\SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx
I use "/testsettings:......\Local.Testsettings" because the Local.testsettings file is 4 levels higher than the level where I am executing this command. You should change it accordingly.
我使用“/testsettings :.......Local.Testsettings”,因为Local.testsettings文件比我执行此命令的级别高4级。你应该相应地改变它。
This is the command used in ccnet.config file
这是ccnet.config文件中使用的命令
<exec>
<executable>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe</executable>
<baseDirectory>SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug</baseDirectory>
<buildArgs>/testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx</buildArgs>
<successExitCodes>0</successExitCodes>
</exec>
#1
13
Finally I resolve my issue.
最后我解决了我的问题。
1) I copied chromedriver.exe in Chrom directory link, but you can put in any directory, I decided to put here.
1)我在Chrom目录链接中复制了chromedriver.exe,但是你可以放入任何目录,我决定放在这里。
2) I Initialized a new instance of the ChromeDriver class using the specified // path to the directory containing ChromeDriver.exe
2)我使用指定包含ChromeDriver.exe的目录的路径初始化了ChromeDriver类的新实例
My code:
我的代码:
IWebDriver drive = new ChromeDriver
("C:\\Documents and Settings\\...\\ApplicationData\\Google\\Chrome\\Application");
And it works just perfect. Thanks All.
它的工作原理非常完美。谢谢大家。
#2
5
Lets assume chromedriver.exe
is present in below path: G:\Selenium_Csharp\Jar\chromedriver_win32\chromedriver.exe
让我们假设chromedriver.exe出现在下面的路径:G:\ Selenium_Csharp \ Jar \ chromedriver_win32 \ chromedriver.exe
To execute your test in Chrome set the path to the directory/folder containing chromedriver.exe
without selecting chromedriver.exe
file name.
要在Chrome中执行测试,请设置包含chromedriver.exe的目录/文件夹的路径,而不选择chromedriver.exe文件名。
driver = new ChromeDriver("G:\\Selenium_Csharp\\Jar\\chromedriver_win32");
driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();
OR
要么
driver = new ChromeDriver(@"G:\Selenium_Csharp\\Jar\\chromedriver_win32");
driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();
#3
2
Install Selenium.Chrome.WebDriver
NuGet package to the project and you will not get the error again.
将Selenium.Chrome.WebDriver NuGet包安装到项目中,您将不会再次收到错误。
In Visual Studio, right click the Project, click Manage NuGet Packages... , Search for Selenium.Chrome.WebDriver and click install.
在Visual Studio中,右键单击“项目”,单击“管理NuGet包...”,“搜索Selenium.Chrome.WebDriver”,然后单击“安装”。
Enjoy Selenium.
享受Selenium。
#4
0
This is the error i see: OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
这是我看到的错误:OpenQA.Selenium.DriverServiceNotFoundException:chromedriver.exe文件不存在于当前目录或PATH环境变量的目录中。
I resolved this problem by specifying the 'testsettings' argument in the command to run the unit tests.
我通过在命令中指定'testsettings'参数来运行单元测试来解决这个问题。
E.g.
例如。
E:\Development\SampleProject\SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx
I use "/testsettings:......\Local.Testsettings" because the Local.testsettings file is 4 levels higher than the level where I am executing this command. You should change it accordingly.
我使用“/testsettings :.......Local.Testsettings”,因为Local.testsettings文件比我执行此命令的级别高4级。你应该相应地改变它。
This is the command used in ccnet.config file
这是ccnet.config文件中使用的命令
<exec>
<executable>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe</executable>
<baseDirectory>SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug</baseDirectory>
<buildArgs>/testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx</buildArgs>
<successExitCodes>0</successExitCodes>
</exec>