获得"没有设置X11 DISPLAY变量,但是该程序执行了一项需要它的操作。"

时间:2016-12-20 21:22:37

标签: java amazon-web-services jenkins selenium-webdriver ivy

我正在通过jenkins集成在AWS上运行测试,此测试需要上传文件,并且上传文件时会打开上传(文件资源管理器)窗口,这会触发错误

[java] [INFO] [2:53:49 PM] Thread-1(TestMethodRunner.java:188) -      [java]没有设置X11 DISPLAY变量,但是该程序执行了需要它的操作。      [java] [INFO] [2:53:49 PM] Thread-1(TestMethodRunner.java:189) - java.awt.HeadlessException:      [java]没有设置X11 DISPLAY变量,但是该程序执行了需要它的操作。      [java] at sun.awt.HeadlessToolkit.getSystemClipboard(HeadlessToolkit.java:307)      [java] at com.proquest.apps.etd.pqaf.layer.FileUploadWindow.uploadingFile(FileUploadWindow.java:50)      [java] at com.proquest.apps.etd.regression.tests.SmokeTest.smokeTest(SmokeTest.java:100)      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      [java] java.lang.reflect.Method.invoke(Method.java:606)      [java] at org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:45)      [java] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)      [java] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)      [java] at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)      [java] at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)      [java] at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)      [java] at org.junit.rules.TestWatcher $ 1.evaluate(TestWatcher.java:47)      [java] at org.junit.rules.TestWatcher $ 1.evaluate(TestWatcher.java:47)      [java] at org.junit.rules.TestWatcher $ 1.evaluate(TestWatcher.java:47)      [java] at org.junit.rules.RunRules.evaluate(RunRules.java:18)      [java] at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)      [java] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)      [java] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)      [java] at org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:231)      [java] at org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:60)      [java] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)      [java] at org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:50)      [java] at org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:222)      [java] at org.junit.runners.ParentRunner.run(ParentRunner.java:300)      [java] at org.junit.runner.JUnitCore.run(JUnitCore.java:157)      [java] at org.junit.runner.JUnitCore.run(JUnitCore.java:136)      [java] at com.proquest.testing.TestMethodRunner.runUnitTest(TestMethodRunner.java:194)      [java] at com.proquest.testing.TestMethodRunner.run(TestMethodRunner.java:62)      [java] at com.proquest.testing.SimpleThread.run(SimpleThread.java:13)

  1. 如何解决此错误,我无法使用putty启用X11,测试是通过Jenkins运行的,测试每天在预定时间自动执行,所以我必须使其动态化?
  2. 是否有任何常春藤依赖关系"没有设置X11 DISPLAY变量和Headless Exception"可以使用。

1 个答案:

答案 0 :(得分:2)

如果您的构建需要X11访问权限,那么您将要使用虚拟帧缓冲区包装jenkins构建。 Jenkins有一个可用的插件来帮助这个名为Xvfb

然后,您想让Jenkins知道如何使用这个新显示器进行测试。

示例:

export DISPLAY=:1.0

其中1.0将是您的虚拟X窗口的名称。