Jenkins上的XVFB连接到错误的显示器.显示屏显示黑屏 [英] XVFB on Jenkins connecting to wrong display. Display shows black screen

查看:114
本文介绍了Jenkins上的XVFB连接到错误的显示器.显示屏显示黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用UBUNTU AWS/VM上的XVFB通过Jenkins执行无头铬Selenium测试.

I am trying to execute headless chrome Selenium tests via Jenkins using XVFB on UBUNTU AWS/VM.

我的Jenkins XVFB配置为:

My Jenkins XVFB config is:

预构建执行Shell:

Pre-build Execute Shell:

export DISPLAY=:98
x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :98 -auth /var/run/lightdm/root/:0 -rfbport 5900

开始构建时,我看到:

Xvfb starting$ /usr/bin/Xvfb :98 -screen 0 1024x768x24 -fbdir /var/lib/jenkins/xvfb-82-..fbdir10942188934689457655
[Jenkins-Headless] $ /bin/sh -xe /tmp/jenkins11502774511620101086.sh
+ export DISPLAY=:98
+ x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :98 -auth /var/run/lightdm/root/:0 -rfbport 5900
17/09/2020 09:50:33 passing arg to libvncserver: -rfbport
17/09/2020 09:50:33 passing arg to libvncserver: 5900
.
.
.

最后:

17/09/2020 09:50:34 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 11460
17/09/2020 09:50:34 Using X display :98
17/09/2020 09:50:34 rootwin: 0x298 reswin: 0x200001 dpy: 0x1a57e8f0
.
.
The VNC desktop is:      jenkins-it02:0
PORT=5900

现在通过我的MAC上的终端,我正在使用ssh -L 5900:localhost:5900 qa_user@my.aws.ip命令连接到VM.

Now via Terminal on my MAC, I am connecting to VM using ssh -L 5900:localhost:5900 qa_user@my.aws.ip command.

并使用VNCViewer,我连接到localhost:5900.它已连接,但我只看到黑屏.我希望屏幕上出现Chrome浏览器窗口.

and using VNCViewer, I am connecting to localhost:5900. It get's connected but I see only a black screen. I am expecting Chrome browser window on the screen.

如何解决此问题并在vncviewer上观看Chrome窗口?

How can I solve this issue and get to watch Chrome window on vncviewer?

推荐答案

我自己找到了解决方案.对于遇到相同问题的任何人:

I found the solution to this myself. For anyone who's having the same issue:

我做错了是我在代码中使用了driver = new ChromeDriver(options);而不是driver = new RemoteWebDriver(new URL("http://my.aws.ip:4444/wd/hub"), options);

What I did wrong was I used driver = new ChromeDriver(options); in my code instead of driver = new RemoteWebDriver(new URL("http://my.aws.ip:4444/wd/hub"), options);

进行此更改后,我在ec2中将selenium-server-standalone.jar下载到了.

After making this change, I downloaded selenium-server-standalone.jar to in EC2.

然后,在开始测试之前,我对ec2进行ssh -X qa_user@my.aws.ip并执行:

Then, before starting the test, I did ssh -X qa_user@my.aws.ip to EC2 and executed:

Xvfb :99 -ac -screen 0 1280x1024x24 &
export DISPLAY=:99
java -jar /home/qa_user/Selenium/selenium-server-standalone.jar

现在,执行测试,同时打开一个新终端并执行以下操作:

Now, execute the test, in parallel I opened a new terminal and did:

ssh -L 5900:localhost:5900 qa_user@my.aws.ip

设置好屏幕后,我就会这样做:

Once the screen was set, I did:

x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :99 -auth /var/run/lightdm/root/:0  -rfbport 5900

接下来,打开VNC查看器,连接到localhost:5900,您将看到Chrome执行.

Next, open VNC viewer, connect to localhost:5900 and you'll see Chrome execution.

稍后,如果需要,您可以将所有这些移至Jenkins预先构建的执行外壳中:)

Later you can move all this to Jenkins pre-build execute shell if required :)

这篇关于Jenkins上的XVFB连接到错误的显示器.显示屏显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆