XVFB on Jenkins connecting to wrong display. Display shows black screen

放肆的年华 提交于 2020-11-29 21:28:31

问题


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

My Jenkins XVFB config is:

Pre-build Execute Shell:

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

When build starts, I see:

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

and finally:

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

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

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.

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


回答1:


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

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);

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

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

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

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



来源:https://stackoverflow.com/questions/63935935/xvfb-on-jenkins-connecting-to-wrong-display-display-shows-black-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!