在Eclipse中使用SeleniumWebDriver和java运行phantomjs

在Eclipse中使用SeleniumWebDriver和java运行phantomjs,java,eclipse,selenium,webdriver,phantomjs,Java,Eclipse,Selenium,Webdriver,Phantomjs,我一直在尝试将我的机器设置为使用SeleniumWebDriver和Eclipse中的java运行phantomjs。我已经能够从使用npm全局安装的命令行运行phantomjs,所以我很确定我只是没有通过Eclipse正确设置它 下面是我如何在测试代码中调用phantomjs的一个片段: @Before public void setUp() throws Exception { dCaps = new DesiredCapabilities(); dCaps.setJavascri

我一直在尝试将我的机器设置为使用SeleniumWebDriver和Eclipse中的java运行phantomjs。我已经能够从使用npm全局安装的命令行运行phantomjs,所以我很确定我只是没有通过Eclipse正确设置它

下面是我如何在测试代码中调用phantomjs的一个片段:

@Before
public void setUp() throws Exception {

  dCaps = new DesiredCapabilities();
  dCaps.setJavascriptEnabled(true);
  dCaps.setCapability("takesScreenshot", false);
  dCaps.setCapability("phantomjs.binary.path", "/usr/local/lib/node_modules/phantomjs/bin/phantomjs");

  driver = new PhantomJSDriver(dCaps);
  baseUrl = "http://assertselenium.com/";
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
在从Eclipse运行测试之前,是否需要手动启动phantomjs或selenium服务器


是否有某些文件应该包含在引导类路径中?

您得到了什么错误/异常?Eclipse日志:org.openqa.selenium.phantomjs.PhantomJSDriverService INFO:executable:/usr/local/lib/node_modules/phantomjs/bin/phantomjs Jun 23,2014年10:02:01 AM org.openqa.selenium.phantomjs.PhantomJSDriverService信息:端口:17255 2014年6月23日10:02:01 AM org.openqa.selenium.phantomjs.PhantomJSDriverService信息:参数:[-webdriver=17255,-webdriver日志文件=/Users/drewdimanlig/Documents/workspace/spark/phantomjsdrive‌​r、 日志]2014年6月23日上午10:02:01 org.openqa.selenium.phantomjs.PhantomJSDriverService信息:环境:{}env:node:没有这样的文件或目录eclipse故障跟踪中的此文件或目录:org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。虽然为时已晚,但解决方案如下:sudo ln-s/usr/local/bin/node/usr/bin/node