将behat与zombieJS一起使用以单击元素,从而产生DriverException

将behat与zombieJS一起使用以单击元素,从而产生DriverException,behat,zombie.js,Behat,Zombie.js,我正在使用behat和僵尸驱动程序来测试我的应用程序。现在我尝试单击一个元素(td),以触发ajax请求。但单击此元素时,我收到错误: 处理事件“单击”时出错(Behat\Mink\Exception\DriverException 我使用的代码来自 在互联网上我找不到有相同错误信息的人,所以我不知道如何解决这个问题 我要单击的HTML如下所示: <td value="2" onclick="switchStatus(this.id); updateScores();; return fa

我正在使用behat和僵尸驱动程序来测试我的应用程序。现在我尝试单击一个元素(td),以触发ajax请求。但单击此元素时,我收到错误:

处理事件“单击”时出错(Behat\Mink\Exception\DriverException

我使用的代码来自

在互联网上我找不到有相同错误信息的人,所以我不知道如何解决这个问题

我要单击的HTML如下所示:

<td value="2" onclick="switchStatus(this.id); updateScores();; return false;" id="37_12_2">2</td>
/**
 * @Given /^I click td "([^"]*)"$/
 */
public function iClickTd($id)
{
    $locator = "#$id";
    $element = $this->getSession()->getPage()->find('css', $locator);

    if (null === $element) {
        throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
    }

    $element->click();
    $this->getSession()->wait(1000);
}
在测试中,我有:

And I click td "37_12_2"
behat.yml:

default:
  suites:
    default:
      contexts:
        - FeatureContext:
          - http://localhost/
  extensions:
    Behat\MinkExtension\ServiceContainer\MinkExtension:
      base_url: http://localhost/
      sessions:
        default:
          goutte: ~
        javascript:
          zombie:
            node_modules_path: '/usr/lib/node_modules/'
使用版本:

  • “phpunit/phpunit”:“4.5.*”
  • “phpspec/phpspec”:“~2.1”
  • “behat/behat”:“~3.0”
  • “behat/mink”:“~1.6”
  • “behat/mink扩展”:“~2.0”
  • “behat/水貂痛风驱动程序”:“*”
  • “behat/mink僵尸驱动程序”:“~1.2”
  • npm v1.4.28
  • PHP5.6

有人知道出了什么问题吗?我如何使这个函数工作?

实际的问题是一个错误的ajax请求。使用真正的webbroser,ajax调用是正确的,但使用zombieJS,此调用指向错误的url

当其他人有相同的异常时,您可以通过更改ZombieDriver.php中的以下部分来查看真正的问题: 发件人:

致:

$out包含ajax调用的实际错误消息

$out = $this->server->evalJS($js);
    if (!empty($out)) {
        throw new DriverException(sprintf("Error while processing event '%s'", $event));
    }
$out = $this->server->evalJS($js);
    if (!empty($out)) {
        echo $out;
        throw new DriverException(sprintf("Error while processing event '%s'", $event));
    }