duanhuanzhi6431 2016-01-23 18:11
浏览 54
已采纳

Behat测试验证消息

I have validation form using JavaScript and I want to test the validation message, because messages are in few languages. However, Behat throws an exception

Could not open connection: Curl error thrown for http POST to

http://localhost:4444/wd/hub/session with params: {"desiredCapabilities":{"tags":["vagrant-ubuntu-trusty-32","PHP 7.0.1-2+deb.sury.org~trusty+1"],"browser":"firefox","ignoreZoomSetting":false,"name":"Behat feature suite","browserName":"firefox"}}

Failed to connect to localhost port 4444: Connection refused (Behat\Mink\Exception\DriverException)

Feature: Validator form contact
  In the contact form  to see a validator message

  @javascript
  Scenario: Message validation in English lang
    Given I am on "/"
    When I fill in "name" with "behat"
    And I fill in "email" with "example@example.com"
    And I fill in "phone" with "111222333"
    And I fill in "message" with "That test message, send via Behat."
    When I press "Send Message"
    Then  I wait for the suggestion box to appear
    Then  I should see "Your message has been sent."

class FeatureContext extends MinkContext {

public function __construct() {
}

/**
 * @Then /^I wait for the suggestion box to appear$/
 */
public function iWaitForTheSuggestionBoxToAppear() {
   $this->getSession->wait(5000, false);
}

behat.yml:

default:
extensions:
  Behat\MinkExtension:
    goutte: ~
    base_url: 'http://localhost.dev/'
    javascript_session: selenium2
    browser_name: firefox
    selenium2: ~

How should I testing that case?

  • 写回答

3条回答 默认 最新

  • douba05167 2016-03-07 14:34
    关注

    Just a quick question, have you started your WebDriver on port 4444?

    Because I replicated the error that you got simply by switching off my chromedriver.

         [Behat\Mink\Exception\DriverException]                                                                                                                                                                                                                                                                                                                     
      Exception has been thrown in "beforeScenario" hook, defined in FeatureContext::windowSizeChange()                                                                                                                                                                                                                                                          
      Could not open connection: Curl error thrown for http POST to http://127.0.0.1:9515/session with params: {"desiredCapabilities":{"browserName":"chrome","version":"8","platform":"ANY","browserVersion":"8","browser":"firefox","name":"Behat test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0","max-duration":300}}  
      Failed to connect to 127.0.0.1 port 9515: Connection refused
    
      [WebDriver\Exception\CurlExec]                                                                                                                                                                                                                                                                                                  
      Curl error thrown for http POST to http://127.0.0.1:9515/session with params: {"desiredCapabilities":{"browserName":"chrome","version":"8","platform":"ANY","browserVersion":"8","browser":"firefox","name":"Behat test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0","max-duration":300}}  
      Failed to connect to 127.0.0.1 port 9515: Connection refused    
    

    For selenium webdriver: java -jar selenium-server-standalone-<versionNumber>.jar -port 4444

    For chromedriver: chromedriver --port=4444

    For operadriver: operadriver --port=4444

    And also, is this segment in your FeatureContext.php?

    default:
     extensions:
      Behat\MinkExtension:
        goutte: ~
        base_url: 'http://localhost.dev/'
        javascript_session: selenium2
        browser_name: firefox
        selenium2: ~
    

    Because if it is, it is in the wrong place, and needs to be in your behat.yml file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?