I use selenium 3 and chrome browser to test but selenium doesn't launch chrome browser. I set chromedriver path: usr/local/bin
this is code behat.yml:
default:
suites:
default:
bundle: MedBundle
contexts:
- test\MedBundle\Behat\Context\FeatureContext
- test\MedBundle\Behat\Context\AjouterContext
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://localhost/test/web/app_dev.php
goutte: ~
browser_name: 'chrome'
javascript_session: selenium2
selenium2:
wd_host: http://localhost:4444/wd/hub
sessions:
default:
symfony2: ~
I have this problem:
help me for resolve this problem , I am blocked
Related
I'm not new to setting up Selenium and Mink, but it always seems to be a hassle. This time I'm trying to get it set up in an ubuntu docker container and I am running into the following error:
Could not open connection: Unable to create new service: ChromeDriverService
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'a75b4026b8e5', ip: '172.20.0.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.60-linuxkit-aufs', java.version: '1.8.0_161'
Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
I can tell that Mink is hitting the Selenium to some degree, since the Selenium server outputs the following immediately before Behat reports the above error:
2018-01-30 16:13:49.870:INFO:osjshC.ROOT:qtp1156060786-12: org.openqa.selenium.remote.server.WebDriverServlet-10bbd20a: Initialising WebDriverServlet
16:13:49.988 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#4b4945b7
16:13:50.006 INFO - /session: Executing POST on /session (handler: BeginSession)
16:13:50.168 INFO - Capabilities are: Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]}
16:13:50.171 INFO - Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
16:13:50.302 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#5a608e4b
16:13:50.303 INFO - /session: Executing POST on /session (handler: BeginSession)
16:13:50.306 INFO - Capabilities are: Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]}
16:13:50.307 INFO - Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Any idea what setting I have wrong?
Here's my setup:
Version of the chromedriver I installed:
https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
Version of Chrome I have installed via the apt-get install google-chrome-stable command:
Google Chrome 64.0.3282.119
Java version that's installed:
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
How I started selenium:
xvfb-run --server-args="-screen 0, 1366x768x24" java -Dwebdriver.chrome.driver="usr/bin/chromedriver" -jar selenium-server-standalone-3.8.1.jar &
composer.json:
...
"require-dev": {
"behat/behat": "^3.1",
"behat/mink": "^1.7",
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
...
},
behat.yml:
extensions:
Behat\MinkExtension:
goutte: ~
base_url: http://localhost/myapp/
browser_name: chrome
javascript_session: selenium2
default_session: goutte
selenium2:
wd_host: "http://127.0.0.1:4444/wd/hub"
capabilities:
marionette: true
browser: chrome
version: 2.9
I'm trying to run Behat on Docker using selenium/hub, selenium/node-chrome-debug and selenium/node-firefox-debug images.
Running Behat with the Chrome node is working, but the Firefox node gives me the following error:
Could not open connection: Payload received from webdriver is valid but unexpected json: {"value":{"sessionId":"244f4715-c59b-4bfc-aa17-8f6a867ead83","capabilities":{"moz:profile":"/tmp/rust_mozprofile.u3mB4xKf6nVD","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"pageLoadStrategy":"normal","moz:headless":false,"moz:accessibilityChecks":false,"acceptInsecureCerts":false,"browserVersion":"57.0","platformVersion":"4.9.60-linuxkit-aufs","moz:processID":1005,"browserName":"firefox","platformName":"linux","moz:webdriverClick":false}}} (Behat\Mink\Exception\DriverException)
When I vnc to Firefox node, I see it opened Firefox, but nothing is happening.
My docker-compose.yml:
version: '3.2'
services:
site.local:
image: webdevops/php-apache-dev:7.1
ports:
- "8888:80"
volumes:
- ./public:/app
- .:/application
selenium-grid-hub.local:
image: selenium/hub
ports:
- "4445:4444"
selenium-node-chrome.local:
image: selenium/node-chrome-debug
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-grid-hub.local
- HUB_PORT_4444_TCP_PORT=4444
ports:
- "5901:5900"
selenium-node-firefox.local:
image: selenium/node-firefox-debug
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-grid-hub.local
- HUB_PORT_4444_TCP_PORT=4444
ports:
- "5902:5900"
My behat.yml:
default:
extensions:
Behat\MinkExtension:
base_url: "http://site.local"
goutte:
guzzle_parameters:
verify: false
suites:
mysuite:
paths: [ %paths.base%/features ]
contexts:
- Zstate\BehatSeleniumDockerSkeleton\Tests\Behat\Context\FeatureContext
chrome:
extensions:
Behat\MinkExtension:
selenium2:
browser: "chrome"
wd_host: http://selenium-grid-hub.local:4444/wd/hub
capabilities: {"browserName": "chrome", "browser": "chrome", 'chrome': {'switches':['--no-sandbox']}}
firefox:
extensions:
Behat\MinkExtension:
selenium2:
browser: "firefox"
wd_host: http://selenium-grid-hub.local:4444/wd/hub
capabilities: {"browserName": "firefox", "browser": "firefox"}
I created this small repo to replicate the issue.
I would greatly appreciate any help or advice. Please let me know if I miss something in my question so I can update it.
In case someone has the same error, this was what helped me.
In my case, the way to solve it was by establishing the following:
for chrome:
capabilities: {"extra_capabilities":{"chromeOptions":{"w3c":false}}}
More info here.
I am working on setting up behavioral tests for our current website. I have used Behat in the past with Selenium standalone server and now have updated to the latest Behat 3 and Selenium 3.5. I am having a multitude of issues though. Using Selenium 3.5 I cannot get xpath selectors to work at all. It is not able to find elements by id, name, class etc. With Selenium 3.4.x it seems to work fine but I cannot get button presses to work. I receive this error:
Then I click button "loginBtn" # FeatureContext::iClickButton()
mouseMoveTo
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'matt-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-59-generic', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver (WebDriver\Exception\UnknownCommand)
This seems to be something that was fixed in 3.5.x with enablePassThrough set to true. Here is my behat.yml configuration.
default:
suites:
default:
contexts:
- FeatureContext:
screenshots_path: '%paths.base%/screenshots/firefox/'
extensions:
Behat\MinkExtension:
base_url: 'http://localhost:8080/customer_portal/'
default_session: selenium2
browser_name: 'firefox'
selenium2:
browser: 'firefox'
capabilities:
browserName: 'firefox'
browser: 'firefox'
version: ''
wd_host: 'localhost:5555/wd/hub'
And inside of my composer.json file
{
"require": {
"behat/behat": "3.*#stable",
"behat/mink": "1.7.*#stable",
"behat/mink-selenium2-driver": "#stable",
"behat/mink-goutte-driver": "#stable",
"behat/mink-extension": "#stable",
"phpmd/phpmd" : "#stable"
},
"config": {
"bin-dir": "bin/"
}
}
I am using Firefox 55 and geckodriver v18. Has anyone successfully configured selenium to work with Behat 3 and Firefox?
It seems to be an issue from Selenium. I also have the issue when working with FF and could not get the Element clicked.
mouseMoveTo error is well known issue when using selenium3. This error happens only for firefox browser with gecko driver. To fix this issue you can use chrome or update the MinkSelenium2Driver library. Should be master branch of MinkSelenium2Driver which requires behat/mink: ~1.7#dev. Here is the point of the problem MinkSelenium2Driver So if its ok for you to use all the latest behat versions, then composer.json could looks like this:
"require": {
"behat/behat": "v3.3.1",
"behat/mink": "v1.7.1",
"behat/mink-extension": "v2.2",
"behat/mink-selenium2-driver": "dev-master",
}
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've been following this guide (and installed everything through composer): http://docs.behat.org/cookbook/behat_and_mink.html and am attempting to get Behat + Mink working but everytime I try and run bin/behat I get the following error:
PHP Fatal error: Call to a member function getSession() on a non-object in vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php on line 80
That line of code is:
return $this->getMink()->getSession($name);
So for some reason the mink attribute is empty but I've no idea why.
My .feature file is exactly the same as the one in the guide, the FeatureContext class is also from the guide:
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
/**
* Features context.
*/
class FeatureContext extends MinkContext
{
}
and my vendor/behat/mink/behat.yml file contains:
context:
extensions:
Behat\MinkExtension\Extension:
base_url: 'http://en.wikipedia.org/'
goutte: ~
selenium2: ~
I've also tried making my class extend BehatContext and then call useContext but that gives me the same error. Behat itself seems to work it's just anything with Mink produces that fatal error and I've no idea how to fix it.
This is because you should copy vendor/behat/behat/behat.yml.dist file to your/project/root/behat.yml, rather than editing the file in the vendor dir and add extesions to the default section.
And here's what it looks like:
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://lunch-time/app_dev.php
goutte: ~
selenium2: ~
paths:
features: features
bootstrap: features/bootstrap
annotations:
paths:
features: features/annotations
closures:
paths:
features: features/closures
I was facing a similar issue. We need to tell Symfony to initialize the object.
Mine got fixed after adding under the default > suites > my_suite.
contexts: [Behat\MinkExtension\Context\MinkContext]
Here is how my new behat.yml looks like.
default:
suites:
my_suite:
type: symfony_bundle
bundle: AcmeProjectManagerBundle
contexts: [Behat\MinkExtension\Context\MinkContext]
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://en.wikipedia.org
goutte: ~
selenium2: ~
sessions:
default:
symfony2: ~