在我的服务器中执行时找不到Phantomjs Behat表单字段

时间:2015-02-11 07:51:17

标签: phantomjs behat mink

大家,请问我能得到一些帮助吗?

我尝试用Behat / Mink和Phantomjs进行测试。它在没有Phantomjs的情况下在本地工作,但不在我的服务器上。

当我启动测试时,我遇到了这个问题:

 @javascript
 Scenario: Searching for a page that does NOT exist                             
Given I am on "http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal" 
When I fill in "searchInput" with "Glory Driven Development"                 
  Form field with id|name|label|value "searchInput" not found.

我在behat.yml中的设置如下

phantomjs:
context:
      class:  'FeatureContext'
  extensions:
    Behat\MinkExtension\Extension:
      goutte: ~
      selenium2:
        wd_host: "http://localhost:8643/wd/hub"
        capabilities:
            proxy:
               proxyType: direct

我的测试如下

@javascript 
Scenario: Searching for a page that does NOT exist
Given I am on "http://fr.wikipedia.org/wiki/WikipC3%A9dia:Accueil_principal"
When I fill in "searchInput" with "Glory Driven Development"
And I press "searchButton"
Then I should see "Search results"

我无法理解为什么它说:“表单字段的id | name | label | value”searchInput“not found”。我推出了phantomjs甚至是硒。

有人有想法吗?谢谢

1 个答案:

答案 0 :(得分:0)

我今天正在尝试同样的情况。

司机抱怨找不到该元素。所以我调试了一下测试用例,发现驱动程序浏览的页面与预期的页面不同。

当司机执行:$this->getSession()->getPage()时。确保您在预期的页面中并收到预期的HTML。