I have difficulties setting the capability PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY
in my Java program correctly in order to use the newest version of Ghostdriver from github together with my installed phantomjs version (1.9.1)
Here is what I do in my Java program
DesiredCapabilities caps = DesiredCapabilities.phantomjs();
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"/xxx/phantomjs-1.9.1-linux-x86_64/bin/phantomjs" );
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY,
"/xxx/ghostdriver/src/main.js");
WebDriver driver = new PhantomJSDriver(caps);
The selenium driver starts correctly, if i do not set the PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY
, but I get some errors in my tests that are supposed to be fixed in the current developer branch of ghostdriver. So i followed this advice and set up the cuttent github version of ghostdriver.
However, now I get the following error:
[ERROR - 2013-07-12T10:22:36.897Z] GhostDriver - Main - Could not start Ghost Driver => {
"message": "Could not start Ghost Driver",
"line": 79,
"sourceId": 140320571924032,
"sourceURL": "/xxx/ghostdriver/src/main.js",
"stack": "Error: Could not start Ghost Driver\n at /xxx/ghostdriver/src/main.js:79",
"stackArray": [
{
"sourceURL": "/xxx/ghostdriver/src/main.js",
"line": 79
}
]
}
My question is, does anyone know how to fix this? Must I change the config.js
of ghostdriver somehow to make this work?
Info: I am crossposting this also to the github issues of ghostdriver.
I fixed this problem by seeing if my port was being used with
netstat -tulnap
That shows you a list of all the ports in use. Find the one that phantomjs is using. Then you can kill the process usingfuser <your-port-number>/tcp -k
. For example, my port was 4444 sofuser 444/tcp -k
Kill any phantomjs process that is running and try again:
Then try running phantomjs again.
So I had the same problem, it was that the port I was attempting to use was already in use. Try a different port. i.e:
I turns out, that this only works as expected for selenium version >= 2.33. I updated my selenium and this fixed the issue.