0
votes

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

My Jenkins XVFB config is: enter image description here

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 [email protected] 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.

enter image description here

enter image description here

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

1

1 Answers

0
votes

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 [email protected] 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 [email protected]

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