Question

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.

Was it helpful?

Solution 4

I turns out, that this only works as expected for selenium version >= 2.33. I updated my selenium and this fixed the issue.

OTHER TIPS

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:

phantomjs --webdriver=8089 --webdriver-selenium-grid-hub=...

Kill any phantomjs process that is running and try again:

ps aux | grep phantom
kill -9 <your phantom process id>

Then try running phantomjs again.

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 using fuser <your-port-number>/tcp -k. For example, my port was 4444 so fuser 444/tcp -k

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top