所以我使用无头浏览器让Behat正常工作,但是我想使用Selenium 2测试一些JavaScript重页。
当我运行vendor / bin / behat时,我在标有@javascript的第一个场景中出现此错误:
Curl error thrown for http POST to http://localhost:4444/wd/hub/session with params: {"desiredCapabilities":{"browserName":"firefox","version":"8","platform":"ANY","browserVersion":"8","browser":"firefox","name":"Behat test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0","max-duration":300},"requiredCapabilities":[]}
couldn't connect to host
当我在配置文件中定义443时,我不知道为什么它连接到错误的端口。为什么说设备类型是表?这是我的behat.yml:
default:
paths:
features: tests/functional/features
bootstrap: tests/functional/features/bootstrap
extensions:
Behat\MinkExtension\Extension:
base_url: http://myvirtualhost.com
goutte: ~
selenium2: ~
context:
parameters:
wd_host: 127.0.0.1:4443/wd/hub
wd_capabilities: { "browser": "firefox", "version": "21"}
我的Selenium 2正好在127.0.0.1:4443/wd/hub运行。
我安装了Firefox 21版。
这是我的composer.json,我有Selenium 2驱动程序:
{
"name": "my-website",
"description": "My Website",
"minimum-stability": "dev",
"require": {
"php": ">=5.3",
"zendframework/zendframework": "2.1.5",
"doctrine/common": "dev-master#d7987c96675e153638729383577090feed9854f1"
},
"require-dev": {
"phpunit/phpunit": "3.7.x-dev#19f1d742e0c36150001062f592c93f80aef3a9fd",
"behat/behat": "dev-develop#1f1bead31e96da5e30fd5d499d5cf66d29b68cf6",
"behat/mink": "v1.4.3",
"behat/mink-extension": "dev-master#ef2c8639ebc254f0ff6e555b7834700caf5db9c4",
"behat/mink-goutte-driver": "dev-master#v1.0.8",
"behat/mink-selenium2-driver": "v1.0.6"
}
}
答案 0 :(得分:11)
您应该在selenium2部分下配置wd_host和wd_parameters,而不是参数:
default:
extensions:
Behat\MinkExtension\Extension:
selenium2:
wd_host: 127.0.0.1:4443/wd/hub
capabilities:
browser: firefox
version: 21
仔细检查wd_host和wd_capabilities是否是正确的参数名称。
答案 1 :(得分:3)
如果它可以帮助任何人,我必须使用"功能"而不是" wd_capabilities"在我的机器上进行这项工作,即:
#behat.yml
default:
extensions:
Behat\MinkExtension\Extension:
base_url: 'http://hostname-of-the.app'
default_session: selenium2
selenium2:
wd_host: 127.0.0.1:4444/wd/hub
capabilities: { "browser": "firefox", "version": "ANY", "selenium-version": "ANY", "deviceType": "ANY"}
SensioLabs\Behat\PageObjectExtension\Extension: ~
Selenium server 2.42.1,Behat 2.5.0。