【问题标题】:Mink > Zombie.js Can't Start SessionMink > Zombie.js 无法启动会话
【发布时间】:2014-09-02 15:59:56
【问题描述】:

我正在尝试使用 Zombie 驱动程序创建 Mink 连接,但出现错误。所有端口均已打开,我已尝试使用我的服务器 IP。

我的代码:

$driver = new \Behat\Mink\Driver\ZombieDriver('127.0.0.1');
$zombieSession = new \Behat\Mink\Session($driver);
$zombieSession->start();

错误:

Fatal error: Uncaught exception 'RuntimeException' with message 'Server process has 
been terminated: (127) [sh: node: command not found ]' in /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php:406
Stack trace: #0 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php(302): 
Behat\Mink\Driver\NodeJS\Server->checkAvailability() #1 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php(107): 
Behat\Mink\Driver\NodeJS\Server->start() #2 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink/src/Behat/Mink/Session.php(62): 
Behat\Mink\Driver\ZombieDriver->start() #3 /home/runniog5/public_html/subdomains/testing4/test.php(114): 
Behat\Mink\Session->start() #4 {main} thrown in /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php 
on line 406

【问题讨论】:

    标签: mink headless-browser zombie.js server-configuration


    【解决方案1】:

    问题是 ZombieServer 不知道节点二进制文件的路径。要解决此问题,请使用以下代码:

    $zombieServer = new ZombieServer($host, $port, $pathToYourNodeBinary, $serverPath, $threshold, $pathToYourNodeModules);
    $zombieDriver = new ZombieDriver($zombieServer);
    $session = new Session($zombieDriver);
    $mink = new Mink(array('zombie' => $session));
    

    在我的例子中,$pathToYourNodeBinary 和 $pathToYourNodeModules 是:

    $pathToYourNodeBinary = '/usr/local/bin/node';
    $pathToYourNodeModules = '/usr/local/lib/node_modules/';
    

    您可以使用这些命令了解您的路径(如果您使用 OSX 运行 Mac):

    which node
    which npm
    

    当然,您需要设置其余的 ZombieServer 构造函数变量。要了解默认值,只需在您的供应商库或 github.com 中查看它的实现@

    【讨论】:

      【解决方案2】:

      确保您已安装 Node 并且它可以正常工作。 Server process has been terminated: (127) [sh: node: command not found ] 告诉你 shell 找不到节点命令。为了验证你已经运行node -v,它应该打印当前安装的版本。

      【讨论】:

      • 我正在运行 node.js 的 v0.10.29
      • 嗯……尝试在Behat/MinkZombieDriver repo 中提高票证,在那里你会有更好的机会。
      猜你喜欢
      • 2017-01-25
      • 2013-07-26
      • 2013-11-27
      • 2017-05-29
      • 2013-08-05
      • 1970-01-01
      • 1970-01-01
      • 2014-03-23
      • 2023-03-10
      相关资源
      最近更新 更多