Selenium webdriver Behat,PhantomJS-单击链接后等待页面加载?

Selenium webdriver Behat,PhantomJS-单击链接后等待页面加载?,selenium-webdriver,phantomjs,behat,ghostdriver,Selenium Webdriver,Phantomjs,Behat,Ghostdriver,我使用的是Behat3和PhantomJS2。目前,我有一个这样定义的场景: @javascript Scenario: I visit the blog through the Blog & Events menu. Given I am an anonymous user And I am on the homepage And I follow "Link Text" Then I should be on "/path-to-page" 当我用痛风做这个的时候没

我使用的是Behat3和PhantomJS2。目前,我有一个这样定义的场景:

@javascript
Scenario: I visit the blog through the Blog & Events menu.
  Given I am an anonymous user
  And I am on the homepage
  And I follow "Link Text"
  Then I should be on "/path-to-page"
当我用痛风做这个的时候没关系。当我用香草硒运行这个程序时,一切正常(我可以看到它启动了一个浏览器)。但是,当我将Selenium配置为将webdriver主机指向PhantomJS时,它会在
上爆炸,然后我应该在“/path to page”
上,声称它仍然在
/

如果我添加以下等待步骤:

@javascript
Scenario: I visit the blog through the Blog & Events menu.
  Given I am an anonymous user
  And I am on the homepage
  And I follow "Link Text"
  And I wait 4 seconds
  Then I should be on "/path-to-page"
然后我的方案通过绿色,一切都好


有没有办法让PhantomJS在检查当前路径之前等待页面加载?我不想依赖任意超时。我需要一个无头解决方案,PhantomJS似乎得到了很好的支持,但是如果我不能做一些简单的事情,比如单击链接并验证加载的页面,而不在任何地方添加随机等待步骤,我可能需要重新评估我的决定。

尝试在功能上下文中使用这种隐式等待。根据我的经验,这是有帮助的

/**
 * @BeforeStep
 */
public function implicitlyWait($event)
{
    // Set up implicit timeouts
    $driver = $this->getSession()->getDriver()->getWebDriverSession();
    $driver->timeouts()->implicit_wait(array("ms" => 10000));
}