【发布时间】:2015-09-21 22:06:29
【问题描述】:
我正在使用 Behat 3 和 PhantomJS 2。目前我有一个这样定义的场景:
@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"
当我用 Goutte 运行它时,它很好。当我使用 vanilla Selenium 运行它时,它很好(它启动了一个我可以看到的浏览器)。但是,当我将 Selenium 配置为将 webdriver 主机指向 PhantomJS 时,它会在 Then I should be on "/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 似乎得到了很好的支持,但是如果我不能做一些简单的事情,比如单击链接并验证加载的页面而不在任何地方添加随机等待步骤,我可能需要重新评估我的决定。
【问题讨论】:
标签: selenium-webdriver phantomjs behat ghostdriver