PHP – 试图在Mac上设置Selenium Behat
作者:互联网
所以我使用无头浏览器让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"
}
}
解决方法:
您应该在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是否是正确的参数名称.
标签:php,selenium-webdriver,behat,mink 来源: https://codeday.me/bug/20190714/1454795.html