I have symfony 3.2.6 app. I have some buttons that make ajax calls so I need to test them with selenium. I installed and configured behat and mink. With standard functional tests without javascript everything works fine. I have my context class that extends MinkContext. My feature file have @javascript tag on top of test. In my virtual machine in /var/www/selenium folder I run selenium server with this command:
DISPLAY=:1 xvfb-run java -jar selenium-server-standalone-3.3.1.jar
This is my behat.yml
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
goutte: ~
selenium2:
wd_host: http://myapp.dev:4444/wd/hub
base_url: http://myapp.dev
javascript_session: selenium2
browser_name: firefox
When I run
php vendor/bin/behat --tags @javascript
I get this error: Could not open connection: Cannot find firefox binary version '9' in PATH Build info: version: '3.3.1', revision: '5234b32'
And if I change browser_name: safari I get this: Could not open connection: The best matching driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver can't create a new driver instance for Capabilities [{deviceType=tablet, selenium-version=2.31.0, marionette=false, browserVersion=9, browser=firefox, name=Behat feature suite, browserName=safari, deviceOrientation=portrait, ignoreZoomSetting=false, version=9, platform=ANY, tags=[myapp.puphpet, PHP 7.0.18]}]
I installed xorg-x11-server-Xvfb, java-1.8.0-openjdk.x86_64, http://selenium-release.storage.googleapis.com/3.3/selenium-server-standalone-3.3.1.jar and firefox.
Did I missed any step?
EDIT:
I run this command:
yum -y install firefox Xvfb libXfont Xorg
and also this one:
yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
I downloaded selenium 2.53.1. If I run startx I get this error:
(gnome-panel:15453): Gtk-WARNING **: A floating object was finalized. This means that someone called g_object_unref() on an object that had only a floating reference; the initial floating reference is not owned by anyone and must be removed with g_object_ref_sink().
When I run
nohup java -jar selenium-server-standalone-2.53.1.jar
I get
nohup: ignoring input and appending output to `nohup.out'
If I run
DISPLAY=:1 xvfb-run java -jar selenium-server-standalone-2.53.1.jar
I get
Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX 09:22:37.189 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver 09:22:37.190 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 09:25:11.183 INFO - Selenium Server is up and running
I tried with ff 52.1.0-2, 45.8.0-2 and 45.7.0-2.
And if I run behat test while selenium server is running I get
Could not open connection: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
You need to use JAR version 2.53, see my article for more details: https://alvinbunk.wordpress.com/2016/08/03/using-mink-to-perform-functional-tests-in-symfony3-framework/
The older JAR supports the older versions of FireFox on Linux. Here's the link to the 2.53.1 JAR you will need: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
EDIT #2 based on comments
Make sure you run this in another console:
export DISPLAY=:1
This is because you are running:
DISPLAY=:1 xvfb-run java -jar selenium-server-standalone-2.53.1.jar