![](/img/trans.png)
[英]Behat testing in laravel with javascript - not using test environment
[英]Behat test validation message
我有使用JavaScript的驗證表單,我想測試驗證消息,因為消息是幾種語言。 然而,Behat引發了一個例外
無法打開連接:http POST引發的卷曲錯誤
http:// localhost:4444 / wd / hub / session with params:{“desiredCapabilities”:{“tags”:[“vagrant-ubuntu-trusty-32”,“PHP 7.0.1-2 + deb.sury.org ~relusty + 1“],”瀏覽器“:”firefox“,”ignoreZoomSetting“:false,”name“:”Behat feature suite“,”browserName“:”firefox“}}
無法連接到localhost端口4444:連接被拒絕(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: ~
我該如何測試這個案子?
只是一個簡單的問題,您是否在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
對於selenium 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文件中。
你可以使用默認的chrome驅動程序來獲取最新的selenium,它只支持chrome瀏覽器。
放入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
使用你的selenium最后一個版本應該是52.3
我嘗試了很多選項來解決這個問題,但對我來說這是chromedriver版本。 我終於通過從http://www.seleniumhq.org/download/下載正確版本的chromedriver來設法修復它,因為我的那個不好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.