Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium driver location search path

I'm trying to set up selenium tests in nCrunch which outputs the tests to its own temp folder.

I'm getting the following error when I create the driver (new PhantomJSDriver()):

OpenQA.Selenium.DriverServiceNotFoundException : The PhantomJS.exe file does not exist in the current directory or in a directory on the PATH environment variable.

However I have checked and PhantomJS.exe does exist in the current directory (\bin\debug).

I then tried using new PhantomJSDriver(".\\") which should be the current directory and that does work.

What is the "current directory" Selenium is referring to in this message?

like image 662
Not loved Avatar asked Nov 02 '15 02:11

Not loved


2 Answers

Rather than assuming ".\\", get the current working working directory by Directory.GetCurrentDirectory or System.AppDomain.CurrentDomain.BaseDirectory . Take a look at Get current folder path.

like image 142
ArunPrakash Avatar answered Nov 10 '22 15:11

ArunPrakash


new PhantomJSDriver() will use your bin folder

if PhantomJS.exe does not exist there, try to find where it's located and insert full path in constructor

new PhantomJSDriver("real_path_to_PhantomJS.exe")
like image 29
Sergiy Matvienko Avatar answered Nov 10 '22 15:11

Sergiy Matvienko