2016-01-23 114 views
5

我使用JavaScript验证表单,我想测试验证消息,因为消息是少数语言的。然而,贝哈特抛出一个异常Behat测试验证消息

无法打开连接:卷曲抛出错误HTTP POST到

http://localhost:4444/wd/hub/session使用参数: { “desiredCapabilities”:{ “标签”:“流浪的Ubuntu的,值得信赖-32“,”PHP 7.0.1-2 + deb.sury.org〜trusty + 1“],”browser“:”firefox“,”ignoreZoomSetting“:false,”name“:”Behat feature suite“, “browserName”:“firefox”}}

无法连接到本地主机端口4444:连接被拒绝(Behat \ Mink \ Exception \ DriverException)

特点:验证形式接触 在接触形式看到验证信息

@javascript 
    Scenario: Message validation in english lang 
    Given I am on "/" 
    When I fill in "name" with "behat" 
    And I fill in "email" with "[email protected]" 
    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." 

类FeatureContext扩展MinkContext {

public function __construct() 
{ 
} 


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




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

我应该如何测试这种情况下?

回答

1

只是一个简单的问题,你是否已经在端口4444上启动了WebDriver?

因为我只是通过关闭我的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  

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

对于chromedriver:chromedriver --port=4444

对于operadriver:operadriver --port=4444

而且也,是这一细分市场中的FeatureContext.php?

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

因为如果是,它是在错误的地方,需要在你的behat.yml文件。

0

您可以使用默认的铬驱动程序为最新的硒,它将只支持铬浏览器。

放于behat.yml

default: 
    autoload: 
    '': %paths.base%/features/bootstrap 
    extensions: 
    Behat\MinkExtension: 
     base_url: your url 
     default_session: selenium2 
     files_path: features/Resources 
     show_cmd: 'open %s' 
     selenium2: 
     browser: chrome 
     wd_host: http://localhost:4444/wd/hub 

使用您的硒最后一个版本应该是52.3

0

我尝试了很多选项来解决这个问题,但对我来说这是chromedriver版本。 我终于设法通过从http://www.seleniumhq.org/download/下载正确版本的chromedriver来解决它,因为我拥有的那个版本并不好。