setting PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY

百般思念 提交于 2019-12-11 07:54:20

问题


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.


回答1:


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=...




回答2:


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.




回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/17613536/setting-phantomjsdriverservice-phantomjs-ghostdriver-path-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!