Selenium, PHP Unit and Firefox on Ubuntu EC2

一曲冷凌霜 提交于 2019-12-11 10:25:44

问题


I am attempting to get PHPUnit tests running with Selenium.

I start up selenium:

java -jar selenium-server-standalone-2.32.0.jar &

Run my tests:

phpunit --verbose suite/TestSuite.php

... and this is where things tend to go wrong on the Selenium RC side. When Selenium attempts to "Preparing Firefox profile..." it errors out due to the following:

ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!

So what I take from that, is that a fresh install of Firefox, there is no original profile created and it wants to make one for the session. Apparently this takes forever and Selenium is timing out because of it.

So I try to make a profile from command line for Firefox that I will then be able to tell Selenium to use.

firefox -CreateProfile selenium

Alas, no joy:

Error: cannot open display: :22

Since this is an EC2 instance, there is no display (X) . So... not sure what my options are now. I tried to run the PHPUnit tests using Chrome browser instead, but for whatever reason, it still want to create a Firefox Profile ... whiskey tango.

If anyone has any suggestions, I would appreciate it.


回答1:


running it headless like so:

export DISPLAY=:0.0
xvfb-run --auto-servernum --server-num=0 java -jar selenium-server-standalone-2.32.0.jar > /dev/null 2>&1 &


来源:https://stackoverflow.com/questions/16040327/selenium-php-unit-and-firefox-on-ubuntu-ec2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!