“无法打开连接”behat和selenium

时间:2014-09-11 12:39:51

标签: firefox selenium behat

我有一个问题,实在不知道它来自哪里。我正在使用behat,selenium和goutte进行测试。

我的behat.yml:

    default:
  paths:
    features: features
    bootstrap: %behat.paths.features%/bootstrap
  extensions:
    Behat\MinkExtension\Extension:
      goutte: ~
      selenium2: ~

我有一个简单的场景:

  @javascript
  Scenario: Searching for "test"
    Given I go to "https://www.google.fr"
    When I fill in "q" with "test"
    And I press "btnG"
    Then I should see "speedtest"

当我运行它时,我的firefox浏览器正在打开,但没有任何反应。结果如下:

  @javascript
  Scenario: Searching for "test"          # features/test.feature:7
    Given I go to "https://www.google.fr" # FeatureContext::visit()
      Could not open connection
    When I fill in "q" with "test"        # FeatureContext::fillField()
    And I press "btnG"                    # FeatureContext::pressButton()
    Then I should see "speedtest"

这很奇怪,因为当我删除“javascript”时,一切都正常运行。所以我认为我的问题来自firefox。而且,打开的firefox浏览器不是“普通”浏览器(characteres很小)。

你能帮帮我吗? :)

1 个答案:

答案 0 :(得分:1)

我遇到了奇怪的Firefox问题并转向Chrome,解决了我的问题。您需要下载Chrome driver

<强> behat.yml

default:
    context:
        class: 'FeatureContext'
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://localhost/local/sport/web/app_test.php/'
            browser_name: 'chrome'
            goutte: ~
            selenium2: ~
    paths:
        features: 'src/Football/TeamBundle/Features'
        bootstrap: %behat.paths.features%/Context

我正在使用这些套餐:

"require-dev": {
    "behat/behat": "2.5.*@stable",
    "behat/behat-bundle": "1.0.0",
    "behat/symfony2-extension": "1.1.2",
    "behat/mink": "1.5.0",
    "behat/mink-extension": "~1.3",
    "behat/mink-selenium2-driver": "1.1.1",
    "behat/mink-goutte-driver": "1.0.9",
    "phing/phing": "2.8.2"
},

工作特征:

Feature: I say hello

@javascript
Scenario: I say hello here
When I go to '/'
Then I fill in "text_hello" with "Hello"