OS - Windows 7
PhantomJS version - 2.1.1
Selenium - 3.8.1(selenium-server).
JDK - 152.
I\'m trying to run simple test, using PhantomJS:
Just to add a different scenario where the same exception can be faced.
While using Eclipse below code was working :
File file = new File("C://phantomjs.exe");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
While using Intellij, the same above code was throwing the error as mentioned in the question.
But the below worked with the Intellij :
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:\\phantomjs.exe");
WebDriver driver = new PhantomJSDriver(capabilities);
Note:Dont forget to change the exe path.