在流浪虚拟机上symfony 3中的behat和水貂硒测试

问题描述:

我有symfony 3.2.6应用程序。我有一些按钮,使ajax调用,所以我需要用硒进行测试。我安装并配置了behat和水貂。使用没有JavaScript的标准功能测试一切正常。 我有我的上下文类扩展MinkContext。 我的功能文件在测试之上有@javascript标记。在在/ var/WWW /文件夹硒我的虚拟机我运行硒服务器使用此命令:在流浪虚拟机上symfony 3中的behat和水貂硒测试

DISPLAY=:1 xvfb-run java -jar selenium-server-standalone-3.3.1.jar 

这是我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 

当我运行

php vendor/bin/behat --tags @javascript 

我得到这个错误: 无法打开连接:在路径中找不到firefox二进制版本'9' Build info:'3.3.1',revision:'5234b32'

如果我更改browser_name:safari,我得到: 无法打开连接:最佳匹配驱动程序提供程序org.openqa.selenium.htmlunit.HtmlUnitDriver无法为Capabilities [{deviceType = tablet ,selenium-version = 2.31.0,marionette = false,browserVersion = 9,browser = firefox,name = Behat features suite,browserName = safari,deviceOrientation = portrait,ignoreZoomSetting = false,version = 9,platform = ANY,tags = [ myapp.puphpet,PHP 7.0.18]}]

我安装了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和firefox。

我错过了任何一步吗?

编辑:

我运行此命令:

yum -y install firefox Xvfb libXfont Xorg 

而且这一个:

yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop" 

我下载硒2.53.1。如果我执行startx我得到这个错误:

(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().

当我运行

nohup java -jar selenium-server-standalone-2.53.1.jar 

我得到

nohup: ignoring input and appending output to `nohup.out'

如果我运行

DISPLAY=:1 xvfb-run java -jar selenium-server-standalone-2.53.1.jar 

我得到

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

我试着用ff 52.1.0-2,45.8.0-2和45.7.0-2。

如果我跑贝哈特测试,而硒服务器运行的是我得到

Could not open connection: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

+0

'Gtk-WARNING'是j那只是一个“警告”,不是一个错误。 'nohup'是你在命令行输入的内容,这是预期的。所以唯一真正的错误是“无法连接到主机127.0.0.1 ...”。 –

您需要使用JAR版本2。53,请参阅我的文章以获取更多详细信息: https://alvinbunk.wordpress.com/2016/08/03/using-mink-to-perform-functional-tests-in-symfony3-framework/

较早的JAR支持Linux上较早版本的FireFox。 这里的链接到2.53.1 JAR你将需要:基于评论 https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar


编辑#2

确保在另一个控制台运行此:

export DISPLAY=:1 

这是因为你正在运行:

DISPLAY=:1 xvfb-run java -jar selenium-server-standalone-2.53.1.jar 
+0

感谢您的回答。我更新了我的问题,因为我仍然有一些错误。如果你能看一看,我将不胜感激。 – KondukterCRO

+0

您是否在另一个控制台窗口中导出DISPLAY =:1?如果解决了问题,我可以更新我的帖子。在发布和提问之前,请尝试进行更多的疑难解答。在我开始工作之前,我花了很多时间研究。这并不容易 - 再加上我没有“求”求助,而是自己想出来了。 –

+0

是的,它解决了它。您可以添加它以回答以供进一步参考。谢谢。 – KondukterCRO