I am trying to run Behat\mink using this code "bin\behat --format html --out report.html --profile firefox" . But i am getting this error .
[RuntimeException]
MinkExtension 1.3 only supports Goutte 1.x for MinkGoutteDriver, not Goutte 2.x.
composer.json looks like this
{
"require": {
"behat/behat": "2.5.*#stable",
"behat/mink": "1.6.*#stable",
"behat/mink-extension": "*",
"behat/mink":"~1.5#dev",
"behat/mink":"~1.6#dev",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/"
}
}
behat.yml
firefox:
context:
parameters:
Browser_Name: firefox
extensions:
Behat\MinkExtension\Extension:
base_url: https://google.com
javascript_session: selenium2
browser_name: firefox
selenium2:
wd_host: http://127.0.0.1:4444/wd/hub
It would be so helpful if you could tell me where i have gone wrong .
I would say that your first problem lies within your composer.json file. It would appear as though you are attempting to load both developmental and stable versions of the same library.
Unless you are attempting to test / load some dev code you can simplify your require section to:
"require": {
"behat/mink-selenium2-driver" : "~1.2",
"behat/mink-goutte-driver" : "~1.1",
"behat/mink-extension" : "~2.0"
}
Your behat/behat, and behat/mink libraries will automatically be pulled in by composer to fulfil the requirements for those libraries.
Information on the tilde operator, within your composer.json file can be found within composers documentation
Again, unless you are using dev based releases you might want to look at omitting:
"minimum-stability": "dev",
Related
I'am using php 7.4.27, laravel framework 8.83.7 and installed Laravel Jetstream.
Login & Register can show. After registered, Then an error notification appears in Laravel:
syntax error, unexpected '#', expecting variable (T_VARIABLE) or '{' or '$'
and in code line 12 :
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'jetstream::components.dropdown-link','data' => ['href' => $href,'#click.prevent' => $#clickPrevent]]); ?>
I won't update to php 8. What should i do?
=====edited=====
composer.json file :
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.75",
"laravel/jetstream": "^2.7",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"livewire/livewire": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Explanation:
The issue comes from the fact that the compiled view version under storage/framework/views is failing to evaluate $#clickPrevent.
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'jetstream::components.dropdown-link','data' => ['href' => $href,'#click.prevent' => $#clickPrevent]]); ?>
This has nothing to do with your current PHP version.
Solution:
I managed to locally reproduce the issue. Here is how I solved it.
Steps:
Publish the Jetstream Livewire components.
Command:
php artisan vendor:publish --tag=jetstream-views
Open the file resources/views/vendor/jetstream/components/switchable-team.blade.php
In the file contents,
Instead of:
<x-dynamic-component :component="$component" href="#" #click.prevent="$root.submit();"> ❌
Use this:
<x-dynamic-component :component="$component" href="#"> ✅
Disclaimer:
Note that this is a temporary solution. Everything works fine for me. As lamented by #IMSoP in a comment, I'm afraid it may affect some unknown functionality. I've opened an issue against the library here:
switchable-team.blade.php compiled Jetstream component throwing an error: syntax error, unexpected token "#", expecting variable or "{" or "$"
Update 10th/April/2022:
Another "more stable" solution stated by #fabpl on the opened Github issue:
I think it's the same bug like [2.x] Fix parse error caused by alpine
shorthand on dynamic-component
#1032
Try to replace #click with x-on:click
https://github.com/laravel/jetstream/issues/1036#issuecomment-1094253898
Addendum:
The issue seems to have been introduced in laravel/jetstream v2.7.2. More specifically Use Alpine's #click.prevent for switching teams.
The good news is that this has been resolved beginning from laravel/jetstream v2.7.3 onwards. More specifically [2.x] Fix parse error caused by alpine shorthand on dynamic-component.
I just tagged v2.7.3 which should fix this. Thanks all 👍
https://github.com/laravel/jetstream/issues/1036#issuecomment-1094332998
Hence, you may simply just upgrade your Jetstream version to v2.7.3 to get the fix. I.e:
Command:
composer update laravel/jetstream:2.7.3
Sample Output:
PS C:\Users\Ivan\Documents\SteveContents\GITHUB\Laravel-8.83.7\laravel-8.83.7> composer update laravel/jetstream:2.7.3
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Upgrading laravel/jetstream (v2.7.2 => v2.7.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downloading laravel/jetstream (v2.7.3)
- Downloading laravel/jetstream (v2.7.3)
- Downloading laravel/jetstream (v2.7.3)
- Downloading laravel/jetstream (v2.7.3)
- Upgrading laravel/jetstream (v2.7.2 => v2.7.3): Extracting archive
...
I use Polymer 2.0 and my build setting is:
"builds": [
{
"name": "bundled",
"bundle": true,
"js": { "compile": true},
"css": { "minify": true },
"html": { "minify": true }
}]
I get "Can’t find variable: babelHelpers" error after build.
The Polymer CLI version that I use is 1.1.0.
EDIT: I was using polymer-cli locally. After installing latest polymer-cli globally, now I get “Constructor requires ‘new’ operator” on safari and “Failed to construct ‘HTMLElement’: Please use the ‘new’ operator, this DOM object constructor cannot be called as a function.” on chrome.
EDIT2: used webcomponents-loader.js instead of webcomponents-lite.js and my problem solved.
I was getting same error. Problem was that index.html is technically my entrypoint in my polymer.json config, but my actual served up entrypoint is another file that comes from my server (_Layout.cshtml since I'm using .NET on my backend). What I needed to do was take the code in my compiled index.html file and move it over to my CSHTML file once I set "compile": true. Problem solved.
I want to run behat 3 with chrome but unable to run the --init
my behat.yml
default:
extensions:
Behat\MinkExtension\Extension:
base_url: 'http://someurl.com'
javascript_session: selenium2
selenium2:
browser: chrome
goutte: ~
my composer.json file is as following:
{
"require-dev": {
"behat/behat": "3.*#stable",
"behat/mink": "1.6.*#stable",
"behat/mink-extension": "#stable",
"behat/mink-goutte-driver": "#stable",
"behat/mink-selenium2-driver": "*",
"peridot-php/webdriver-manager": "dev-master",
"bossa/phpspec2-expect": "*"
},
"config": {
"bin-dir": "bin"
}
}
getting the following error
[Behat\Testwork\ServiceContainer\Exception\ExtensionInitializationException]
Behat\MinkExtension\Extension extension file or class could not be located.
As it seems
Behat\MinkExtension\Extension extension file or class could not be located.
You need to remove Extension from behat.yml
Replace Behat\MinkExtension\Extension: with Behat\MinkExtension:
After this it should work.
Try changing your extensions block in the yml configurations file to something like this:
extensions:
Behat\MinkExtension:
base_url: "http://www.your-web.com/"
sessions:
chrome_mac:
selenium2:
browser: "chrome"
wd_host: http://xxx.xxx.xxx.xxx:4444/wd/hub
capabilities:
platform: WINDOWS
browser: chrome
version: ""
extra_capabilities:
chromeOptions:
args:
- "--start-maximized"
The "extra_capabilities section is optional.
This should do the trick!
thanks all i have fixed with the followings:
Behat.yml
default:
extensions:
Behat\MinkExtension:
base_url: myURL.com
selenium2: ~
browser_name: 'chrome'
suites:
defaults:
contexts:
- FeatureContext
- Behat\MinkExtension\Context\MinkContext
composer.json
{
"require": {
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3"
}
}
Java in CLI
java -jar -Dwebdriver.gecko.driver=geckodriver.exe seleneiumversionhere
I use default chrome browser only, I think may work to you, cause I do this every in my project test.
default:
autoload:
'': %paths.base%/features/bootstrap
extensions:
Behat\MinkExtension:
base_url: https://www.test your url.com
default_session: selenium2
files_path: features/Resources
show_cmd: 'open %s'
selenium2:
browser: chrome
wd_host: http://localhost:4444/wd/hub
I am using behat 2.4(stable), and I am trying to pass parameters into class's, that extends BehatContext class, constructor.
However I get 'Unrecognized options "suites" under "behat"', with the following set up.
I am using the following behat.yml file:
default:
suites:
default:
contexts:
exampleContext:
browser: http://localhost:8080
browser_version: /var/tmp
paths:
features: %behat.paths.base%/../../
bootstrap: %behat.paths.base%/../../
extensions:
Behat\MinkExtension\Extension:
# base_url is the URL to your dev site. Make sure you include
# the port at the end. e.g.
base_url: http://example.web01.com
default_session: selenium2
browser_name: 'chrome'
selenium2:
capabilities: { "browser": "firefox", "version": "14"}
sites/all/libraries/extensions/DrupalBehatExtension.php: ~
filters:
# The default profile does not rebuild from nothing so do not run tests
# that require a rebuild from nothing.
tags: ~#require-rebuild
context:
class: DrupalContext
parameters:
# If you'd like to test on a clone of the actual site data set to true.
use_test_database: false
# If an existing test database exists then it will be used unless reset_database is set to true.
reset_database: false
# If you would like to clear the db and run site install on every feature
# set to the name of an install profile, otherwise set to false.
# If you do set this you should also set use_test_database to true.
rebuild_on_feature: false
# If you would like to enable a module after running site install
rebuild_module: false
# Set the name of the site folder to use for settings.php.
site: dev.example.com
My class implementation is
class exampleContext extends BehatContext {
public function __construct($browser = 'ie', $browser_version = '8') {
...
}
How can I achieve this? The only answer I've found is the one that demands to take out the DrupalContext which is rather important.
How can i get the Parameters from Behat.yml to a php file?
suites option was added in behat3. You should update version.
Try this. This is for Behat 2 not 3 though!
mySymfonyProject/composer.json:
"require": {
"behat/behat": "2.5.*#stable",
"behat/behat-bundle": "1.0.0",
"behat/symfony2-extension": "1.1.2",
"behat/mink": "1.5.0",
"behat/mink-extension": "~1.3",
"behat/mink-selenium2-driver": "1.1.1",
"behat/mink-goutte-driver": "1.0.9"
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev",
behat.yml
default:
context:
class: FeatureContext
parameters:
browser: 'ie'
browser_version: '8'
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Behat\MinkExtension\Extension:
base_url: 'http://mysymfonyproject.local/app_test.php/'
javascript_session: selenium2
browser_name: firefox
goutte: ~
selenium2: ~
paths:
features: %behat.paths.base%/src
bootstrap: %behat.paths.features%/Context
CONTEXT FEATURE
mySymfonyProject/src/Site/CommonBundle/Features/Context/FeatureContext.php
<?php
namespace Site\CommonBundle\Features\Context;
use Behat\MinkExtension\Context\MinkContext;
class FeatureContext extends MinkContext
{
public function __construct($browser, $browser_version)
{
// Do whatever you wish with params
}
//And your own methods
}
TESTS
When you have feature files you can run them like this (this runs all in one go. for more info read behat doc):
bin/behat #SiteCommonBundle
I've run some tests with the predefined step definitions of Mink Extension. They work as long as they're in english language.
Now I've tried the following scenario with german steps:
# language: de
Funktionalität: Demo
#javascript
Szenario: Test 1
Angenommen I am on "/"
Angenommen ich bin auf "/"
...
Behat now tells me that the german step definition is undefined, while the english version works.
According to the CLI help, behat --lang de -dl should display the translated definitions, but it only shows me the english ones ...
What am I doing wrong here?
Edit:
Here's a script to rebuild the scenario. It follows the install steps from the docs (http://extensions.behat.org/mink/#through-phar) in a temporary directory and runs the test feature file.
#!/bin/bash
set -e
TEMPDIR=/tmp/behat-$$
mkdir $TEMPDIR
cd $TEMPDIR
curl http://behat.org/downloads/behat.phar >behat.phar
curl http://behat.org/downloads/mink.phar >mink.phar
curl http://behat.org/downloads/mink_extension.phar >mink_extension.phar
cat >behat.yml <<EOF
default:
extensions:
mink_extension.phar:
mink_loader: 'mink.phar'
base_url: 'http://behat.org'
goutte: ~
EOF
mkdir features
cat >features/test.feature <<EOF
# language: de
Funktionalität: Demo
Szenario: Öffne Startseite DE + EN
Angenommen I am on "/"
Angenommen ich bin auf "/"
EOF
php behat.phar
Basically you didn't do anything wrong.
Although the translation of Behat/Gherkin itself is included in the behat.phar file, the translations of the step definitions from MinkExtension are missing in the mink_extension.phar archive.
This seems to be the case because the build script only includes the files in MinkExtension/src/ without MinkExtension/i18n/. You could open an issue for MinkExtension at to get this fixed.
As a workaround I suggest to install Behat/Mink using composer instead of working with phar archives.
Create the following composer.json file:
{
"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/"
}
}
and then install it with:
curl http://getcomposer.org/installer | php
php composer.phar install