我试图在Bamboo弹性实例中运行功能测试。我想在Bamboo Amazon x86_64服务器上运行我的功能测试。在Amazon Linux:默认图像EBS i386(linux)弹性实例中,我安装了Firefox 17.0.1版本来运行我的功能测试。从我的本地机器我希望每晚在我的构建中运行Elastic实例中的功能测试。但是,我收到配置错误。 在功能测试pom文件中:
<executions>
<execution>
<id>xvfb</id>
<phase>pre-integration-test</phase>
<goals>
<goal>xvfb</goal>
</goals>
<configuration>
<display>:2.0</display>
</configuration>
</execution>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
</executions>
要在Elastic实例中运行无头硒测试,我从pom文件中的build开始Xvfb
(X虚拟帧缓冲区)并将Display设置为:2.0
我的测试类设置运行Firefox:
private WebDriver driver;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
在Elastic实例中,这是我进行配置的方式:
已安装firefox版本17.0.1。
还使用命令yum install xorg-x11-server-Xvfb
在Elastic实例中安装了Xvfb服务器,以便在命令行中将Display变量设置为:2.0:export DISPLAY=:2.0
然后当我在命令行中键入Firefox时,它会显示
error:cannot open display=:2.0
全部设置为运行我的测试。
当我运行测试时,Selenium服务器是v2.40.0
它显示Xvfb
已启动。我检查了弹性实例以查看Xvfb
是否正在运行ps aux | grep -i xvf.
它正在运行为Xvfb:2.0
一切进展顺利但是在测试时它无法找到Firefox。
[INFO] Starting Xvfb...
[INFO] Using display: :2.0
[INFO] Using Xauthority file: /tmp/AT-RSTEN-JOB1/Xvfb5480072413528139773.Xauthority
Deleting: /tmp/AT-RSTEN-JOB1/Xvfb5480072413528139773.Xauthority
xauth: creating new authority file /tmp/AT-RSTEN- JOB1/Xvfb5480072413528139773.Xauthority
Created dir: /home/bamboo/bamboo-agent-home/xml-data/build-dir/AT-RSTEN-JOB1/target/selenium
Launching Xvfb
Waiting for Xvfb...
[INFO] Redirecting output to: /home/bamboo/bamboo-agent-home/xml-data/build-dir/AT-RSTEN-JOB1/target/selenium/xvfb.log
Xvfb started
[INFO]
[INFO] --- selenium-maven-plugin:2.3:start-server (default) @ functionalTests ---
Launching Selenium Server
Waiting for Selenium Server...
[INFO] Including display properties from: /home/bamboo/bamboo-agent-home/xml-data/build-dir/AT-RSTEN-JOB1/target/selenium/display.properties
[INFO] User extensions: /home/bamboo/bamboo-agent-home/xml-data/build-dir/AT-RSTEN-JOB1/target/selenium/user-extensions.js
INFO [org.openqa.selenium.server.SeleniumServer] Java: Oracle Corporation 23.25-b01
INFO [org.openqa.selenium.server.SeleniumServer] OS: Linux 3.4.48-45.46.amzn1.x86_64 amd64
INFO [org.openqa.selenium.server.SeleniumServer] v2.40.0, with Core v2.40.0. Built from revision 4c5c0568b004f67810ee41c459549aa4b09c651e
INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: LINUX
INFO [org.openqa.selenium.server.SeleniumServer] RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
INFO [org.openqa.jetty.http.HttpServer] Version Jetty/5.1.x
INFO [org.openqa.jetty.util.Container] Started HttpContext[/selenium-server/driver,/selenium-server/driver]
INFO [org.openqa.jetty.util.Container] Started HttpContext[/selenium-server,/selenium-server]
INFO [org.openqa.jetty.util.Container] Started HttpContext[/,/]
INFO [org.openqa.jetty.util.Container] Started org.openqa.jetty.jetty.servlet.ServletHandler@435879e8
INFO [org.openqa.jetty.util.Container] Started HttpContext[/wd,/wd]
INFO [org.openqa.jetty.http.SocketListener] Started SocketListener on 0.0.0.0:4444
INFO [org.openqa.jetty.util.Container] Started org.openqa.jetty.jetty.Server@42ac76c0
INFO - Checking Resource aliases
Selenium Server started
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default) @ functionalTests ---
[INFO] Surefire report directory: /home/bamboo/bamboo-agent-home/xml-data/build-dir/AT-RSTEN-JOB1/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.bob.LoginTestSelenium
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
Error: no display specified
at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:112)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:192)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:96)
at com.bob.LoginTestSelenium.setUp(LoginTestSelenium.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Results :
Tests in error:
testWrongUsernameCorrectPassword(com.bob.LoginTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testWrongUsernameCorrectPassword(com.bob.LoginTestSelenium)
testLogin(com.bob.LoginTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testLogin(com.bob.LoginTestSelenium)
testRememberMeFunctionLogoutLogin(com.bob.LoginTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testRememberMeFunctionLogoutLogin(com.bob.LoginTestSelenium)
testRememberMeFunctionChangeUsername(com.bob.LoginTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testRememberMeFunctionChangeUsername(com.bob.LoginTestSelenium)
testWrongPassword(com.bob.LoginTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testWrongPassword(com.bob.LoginTestSelenium)
testRememberMeFunctionNotTicked(com.bob.LoginTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testRememberMeFunctionNotTicked(com.bob.LoginTestSelenium)
testAddingActionsToAnAlertUpdatesTheAnimalHistory(com.bob.EstrusAlertsTestSelenium): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:
testAddingActionsToAnAlertUpdatesTheAnimalHistory(com.bob.EstrusAlertsTestSelenium)
Tests run: 14, Failures: 0, Errors: 14, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6:36.882s
[INFO] Finished at: Thu Mar 27 15:23:35 UTC 2014
[INFO] Final Memory: 23M/60M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default) on project functionalTests: There are test failures.
[ERROR]
[ERROR] Please refer to /home/bamboo/bamboo-agent-home/xml-data/build-dir/AT-RSTEN-JOB1/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Deleting: /tmp/AT-RSTEN-JOB1/Xvfb5480072413528139773.Xauthority
Failing task since return code of [/opt/maven-3.0/bin/mvn --batch-mode -Djava.io.tmpdir=/tmp/AT-RSTEN-JOB1 clean install] was 1 while expected 0
Parsing test results...
Finished task 'Maven 3.x'
Running post build plugin 'Artifact Copier'
Running post build plugin 'NCover Results Collector'
Running post build plugin 'Clover Results Collector'
Finalising the build...
Stopping timer.
Build AT-RSTEN-JOB1-82 completed.
Running on server: post build plugin 'Clover Delta Calculator'
Running on server: post build plugin 'Build Hanging Detection Configuration'
Running on server: post build plugin 'NCover Results Collector'
Running on server: post build plugin 'Maven Dependencies Postprocessor'
All post build plugins have finished
Generating build results summary...
Saving build results to disk...
Indexing build results...
Finished building AT-RSTEN-JOB1-82.
有人可以帮我解决这个问题吗?
我是否错过了在弹性实例中设置Firefox的一些配置?
什么是&#34; failed to connect to Firefoxbinary(usr/bin/firefox)
&#34;?我必须在哪里指明这个?我是否需要在功能测试设置中添加此Firefox二进制文件才能运行Firefox?
答案 0 :(得分:0)
这里有几件事。 让我们一步一步尝试。
首先,登录ec2实例并运行以下命令..
Xvfb:1-screen 0 1280x768x24&amp;
export DISPLAY =:1
现在尝试从命令行运行firefox。让我知道这是否有效而不会给你一个错误。