java-RobotFramework SwingLibrary:测试无法通过SSH进行

这是一个痛苦的问题.我有一个Java Swing应用程序,正在尝试将Robot Framework与SwingLibrary一起使用进行测试.我正在做一个无所事事的盒子.我有一个这样的运行脚本,它将开始测试:

export CLASSPATH=swinglibrary-1.8.0.jar:echoapp.jar
export JAVA_OPTS="-Djava.awt.headless=true"
jython `which robot` --loglevel DEBUG test.robot

当我在VM中运行该脚本时,该脚本可以正常运行.但是,如果我通过SSH运行它,则无法正常运行.我看到以下错误消息:

[ ERROR ] Error in file '/vagrant/robotTests/test.robot': Getting keyword 
names from library 'SwingLibrary' failed: Calling dynamic method 
'getKeywordNames' failed: ExceptionInInitializerError

我很困惑.我最初以为是X11问题,​​但是后来我打开了X11转发,用Putty连接到Vagrant盒中,然后将应用程序放在X11窗口中.

搜寻错误并不是超级有帮助.有人吗在这个问题上,我受到的伤害非常严重.

解决方法:

好吧,这就是我的问题所在.尽管设置了X11转发,但X服务器没有合作.由于无论如何我都准备在Jenkins中运行这些测试,因此从长远来看,这对我没有帮助-我将需要备用X Server.

幸运的是,我不是第一个尝试进行GUI测试的人.事实证明,有一种X服务器设计用于无头系统,称为X虚拟帧缓冲区(Xvfb).从the Wikipedia article开始:

Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output. From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to have a screen or any input device. Only a network layer is necessary.

在CentOS / RHEL上,默认存储库中提供了xorg-x11-server-Xvfb软件包.

Available Packages
Name        : xorg-x11-server-Xvfb
Arch        : x86_64
Version     : 1.17.2
Release     : 22.el7
Size        : 843 k
Repo        : base/7/x86_64
Summary     : A X Windows System virtual framebuffer X server.
URL         : http://www.x.org
License     : MIT and GPLv2
Description : Xvfb (X Virtual Frame Buffer) is an X server that is able to run on
            : machines with no display hardware and no physical input devices.
            : Xvfb simulates a dumb framebuffer using virtual memory.  Xvfb does
            : not open any devices, but behaves otherwise as an X display.  Xvfb
            : is normally used for testing servers.

要安装它:

sudo yum -y install xorg-x11-server-Xvfb

一旦完成,我可以使用xvfb-run命令在我的环境中运行Shell脚本.

[vagrant@localhost robotTests]$xvfb-run ./run.sh
==============================================================================
Test
==============================================================================
Test <Redacted One>                                                   | PASS |
------------------------------------------------------------------------------
Test <Redacted Two>                                                   | PASS |
------------------------------------------------------------------------------
Test <Redacted Three>                                                 | PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
3 critical tests, 3 passed, 0 failed
3 tests total, 3 passed, 0 failed
==============================================================================
Output:  /vagrant/robotTests/output.xml
Log:     /vagrant/robotTests/log.html
Report:  /vagrant/robotTests/report.html
上一篇:如何修复MySql:索引列大小太大(Laravel migrate)


下一篇:vagrant 虚拟机搭建 以及virtualbox 安装 配置