本文介绍了Ubuntu EC2上的Selenium,PHP Unit和Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让Selenium运行PHPUnit测试.

I am attempting to get PHPUnit tests running with Selenium.

我启动硒:

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

运行我的测试:

phpunit --verbose suite/TestSuite.php

...这就是Selenium RC方面容易出错的地方.当Selenium尝试正在准备Firefox配置文件..."时,由于以下原因而出错:

... 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!

所以我从中得到的是,是全新安装的Firefox,没有创建原始配置文件,它想为该会话创建一个配置文件.显然,这需要永远的时间,Selenium正因为此而超时.

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.

因此,我尝试从命令行为Firefox创建一个配置文件,然后我将告诉Selenium使用该配置文件.

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

A,不高兴:

Error: cannot open display: :22

因为这是EC2实例,所以没有显示(X).所以...不确定我现在有什么选择.我尝试改用Chrome浏览器运行PHPUnit测试,但是出于某种原因,它仍然想要创建Firefox个人资料...威士忌探戈.

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.

推荐答案

像这样无头运行它:

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

这篇关于Ubuntu EC2上的Selenium,PHP Unit和Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:57