I'm having a lot of trouble with setting up behat + mink for my laravel project.
The error msg:
PHP Deprecated: The ability to pass file names to Yaml::parse() was deprecated in 2.7
and will be removed in 3.0. Please, pass the contents of the file instead. in
home/user/projects/php/projectname/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php
on line 58
[Behat\Testwork\ServiceContainer\Exception\ExtensionInitializationException]
`Behat\MinkExtensions\Extension` extension file or class could not be located.
My composer.json:
"require": {
"laravel/framework": "4.2.*",
"behat/behat": "~3.0.6",
"behat/mink": "1.6.*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium-driver": "*",
"behat/mink-selenium2-driver": "*",
"behat/mink-sahi-driver": "*",
"behat/mink-zombie-driver": "*"
My behat.yml (located in the root of the project)
default:
extensions:
Behat\MinkExtensions\Extension:
goutte: ~
I've tried different versions, but still same error msg.
The commands I've run are:
./vendor/bin/behat --init
./vendor/bin/behat
But produces same msg.
https://github.com/Behat/MinkExtension/blob/master/doc/index.rst
Reading the above solved the problem and the behat.yml should look like this.
# behat.yml
default:
# ...
extensions:
Behat\MinkExtension:
base_url: 'http://example.com'
sessions:
default:
goutte: ~
Related
I am trying to setting up Codeception with Yii2 Basic framework. Unit Test's are working fine. Acceptance is also working, but if I want to use WebDriver module, I get error. This is the acceptance.suite.yml file
class_name: AcceptanceTester
modules:
enabled:
- AcceptanceHelper
- WebDriver:
url: 'http://mylocalsite'
browser: phantomjs
Phantomjs is installed and running on PORT 4444.
The error I get is:
[yii\base\ErrorException]
Illegal offset type in isset or empty
This is the composer file to give you idea about versions.
{
"config": {
"vendor-dir": "protected/vendor"
},
"require": {
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"guzzlehttp/guzzle": "4.*",
"mobiledetect/mobiledetectlib" : "2.8.8",
"codeception/codeception": "2.0.16",
"codeception/specify": "*",
"codeception/verify": "*",
"yii2tech/sitemap": "*",
"geoip2/geoip2":"~2.0",
"facebook/facebook-instant-articles-sdk-php": "^1.5"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-composer": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
}
Is there any wrong with the configuration file or anyone face the same issue?
The following is just an assumption and is not verified. YAML configuration in old Codeception version was slightly different, AFAIK there was an additional config section. Your composer.json shows that you manually locked to "codeception/codeception": "2.0.16".
What you could try:
Update to 2.2
using "codeception/codeception": "^2.2" in composer.json
Provide additional config section
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
config:
WebDriver:
url: http://mylocalsite
browser: phantomjs
port: 4444
I want to use behat to example test and I used Mink and Selenium to test javascript. I have a a element in html file and when I click on the link then JQuery add to DOM new element. I want to test this case.
composer.json
{
"require": {
"behat/behat": "^3.1",
"bossa/phpspec2-expect": "^1.0",
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink": "^1.7"
}
}
behat.yml
default:
extensions:
Behat\MinkExtension:
goutte: ~
browser_name: firefox
selenium2:
wd_host: http://0.0.0.1:4444/wd/hub
example.feature
Feature: example
Scenario: Test javascript for
Given I am on "http://www.example.com/"
When I follow "clickButton" #a has id clickButton
Then I should see "Works!"
Behat throw error in Then I should see "Works!" step and it is fine, because this element not exists on body.
But when add #javascript annotation
#javascript
Feature: example
Scenario: Test javascript for
Given I am on "http://www.example.com/"
When I follow "clickButton"
Then I should see "Works!"
Behat throw exception:
When I follow "clickButton" # FeatureContext::clickLink()
Link with id|title|alt|text "clickButton" not found. (Behat\Mink\Exception\ElementNotFoundException)
What's wrong? I have Selenium on server.
When I call bin/behat to execute my tests, I get this error:
test.dev bin/behat
[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [2002] No such file or directory
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
This is my composer.json:
{
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"magetest/magento-behat-extension": "dev-develop",
"magetest/magento-phpspec-extension": "~2.0",
"peridot-php/webdriver-manager": "dev-master",
"bossa/phpspec2-expect": "dev-master",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"behat/mink-selenium-driver": "*"
},
"autoload": {
"psr-0": {
"": [
"html/app",
"html/app/code/community",
"html/app/code/core",
"html/lib"
],
"Mage" : "html/app/code/core"
}
},
"config": {
"bin-dir": "bin"
}
}
And this is my behat.yml:
default:
paths:
features: features
bootstrap: features/bootstrap
extensions:
MageTest\MagentoExtension\Extension: ~
Behat\MinkExtension\Extension:
base_url: http://test.dev
goutte: ~
selenium2: ~
default_session: selenium2
It's a patchwork of several tutorials while every of them threw the same error. My Magento installation is in html under project. Only thing that differs to all tutorials is, that I have no html/app/code/local folder.
Composer install and behat --init run without errors.
Edit:
I'm working with MAMP Pro, so I found this issue. But linking the socket file to /tmp did not fix my problem.
Since I use MAMP, I have to configure it for CLI as well:
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
Now CLI uses my MAMP PHP version and everything runs well.
I cannot get Mink/Behat to find the default step for the phrase
Then I should see "some text" in the element "element"
Here is my thepage.feature file:
Feature: Page Works
In order to use the page
As a visitor
I need to be able to load it and see content
Scenario: Navigating to the page
Given I am on "mypage.php"
#Then I should see "some text"
#Then the "body" element should contain "sometext"
#Then I should see "sometext" in the "body" element
My FeatureContext extends MinkContext so I don't see why the lower two Then statements come up as undefined, but the upper one works.
Scenario: Navigating to the page # features\wikipedia.feature:6
Given I am on "thepage.php" # FeatureContext::visit()
Then I should see "sometext" in the element "body"
1 scenario (1 undefined)
2 steps (1 undefined)
Since the Given statement works, I don't understand what could be wrong! Surely it can't be the yml file or composer.json?
composer.json:
{
"require": {
"behat/behat": "2.4.*#stable",
"behat/mink": "1.4.*#stable",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/"
}
}
behat.yml:
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://localhost
goutte: ~
selenium2: ~
Where else could the problem be? Thanks
Try to use
Then I should see "sometext" in the "body" element
instead of
Then I should see "sometext" in the element "body"
Here is MinkContext method description
Try with these (got it from here):
composer.json
"require-dev": {
"behat/behat": "2.5.5",
"behat/mink-extension": "1.3.3",
"behat/mink": "1.5.0",
"behat/symfony2-extension": "1.1.2",
"behat/mink-selenium2-driver": "1.1.1",
"behat/mink-browserkit-driver": "1.1.0",
"behat/mink-goutte-driver": "1.0.9"
}
behat.yml
default:
formatter:
name: pretty
parameters:
output_styles:
comment: [ magenta ]
context:
class: Application\BackendBundle\Features\Context\FeatureContext
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Behat\MinkExtension\Extension:
base_url: 'http://football.local/app_test.php/'
javascript_session: selenium2
browser_name: firefox
goutte: ~
selenium2: ~
paths:
features: %behat.paths.base%/src
bootstrap: %behat.paths.features%/Context
For more examples, look here
I am running Ubuntu 12.04.3 LTS and my php version is 5.5.9-1+sury.org~precise+1. I want to test a web page, so included in my project behat, mink and its goutte extension using composer.
When I run behat in the terminal I get the following error:
PHP Warning: require(goutte): failed to open stream: No such file or directory in /home/andreea/public_html/vendor/behat/behat/src/Behat/Behat/Extension/ExtensionManager.php on line 112
PHP Fatal error: require(): Failed opening required 'goutte' (include_path='.:/usr/share/php:/usr/share/pear') in /home/andreea/public_html/vendor/behat/behat/src/Behat/Behat/Extension/ExtensionManager.php on line 112
My composer.json file looks like this:
{
"name": "glp/glp",
"description": "My page",
"require": {
"paymill/paymill": "v3.0.0",
"behat/behat": "2.4.*#stable",
"behat/mink": "1.5.*#stable",
"behat/mink-goutte-driver": "*",
"behat/mink-extension": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/"
}
}
And behat.yml is:
default:
paths:
features: features
bootstrap: %behat.paths.features%/bootstrap
extensions:
Behat\MinkExtension\Extension:
goutte: ~
I need some help to make it work. Thanks!
You're missing one level of indentation in front of goutte:
default:
paths:
features: features
bootstrap: %behat.paths.features%/bootstrap
extensions:
Behat\MinkExtension\Extension:
goutte: ~