My Selenium headless tests are triggered from Jenkins server and run in EC2-Ubuntu. I want to view the test live on Chrome so I installed Xvfb plugin on Jenkins.

On EC2 I installed Xvfb. When I start executing the build, my test starts execution and I see below logs:

Xvfb  /usr/bin/Xvfb :1 -fbdir /var/lib/jenkins/xvfb-27-..fbdir13700092919317283985
Parsing POMs
Established TCP socket on 30810

and I see the test is running successfully.

Now I do SSH to EC2 from Mac terminal by

ssh -L 5901:localhost:5901 [email protected]

Then I execute:

qa_user@jenkins-it:~$ export DISPLAY=: 30810 (Port number from Jenkins logs above)
qa_user@jenkins-it:~$ vncserver "$DISPLAY" -geometry 1280x1024

New 'X' desktop is jenkins-it: 30810

Starting applications specified in /home/qa_user/.vnc/xstartup Log file is /home/qa_user/.vnc/jenkins-it: 30810.log

qa_user@jenkins-it:~$ x11vnc --listen -rfbport 5901 -display : 30810

This starts XVFB and I see:

Display when XVFB starts

Now when I connect from Mac to localhost:5901 from VNCviewer, I am taken to Ubuntu desktop.

Ubuntu desktop via VNCviewer

But I don't see chrome opening up even though the test is running and I see test logs on Jenkins.

I am also able to use Chrome via VncViewer. Using Chorme manually via VNCViewer

What am I missing here? I tried many Xvfb set up instructions and has been trying to get this right since a month now. Here are few questions I asked:

Looking for a solution to run selenium tests on EC2 with GUI

Long way till here and now Stackoverflow is my last resort. Please help.

  • 1
    Headless means you cannot see UI. , Try doing the same with non headless mode and verify whether you can see chrome opening
    – PDHide
    Commented Aug 21, 2020 at 20:23
  • I get below error if I remove options.addArguments("--headless"); from my code. org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
    – Afsal
    Commented Aug 22, 2020 at 6:11
  • options.addArguments("--no-sandbox") try adding this
    – PDHide
    Commented Aug 22, 2020 at 7:47
  • options.merge(capabilities);options.addArguments("start-maximized"); options.addArguments("enable-automation"); options.addArguments("--no-sandbox"); options.addArguments("--disable-infobars"); options.addArguments("--disable-dev-shm-usage"); options.addArguments("--disable-browser-side-navigation"); options.addArguments("--disable-gpu"); No sandbox is already added. This is my current code.
    – Afsal
    Commented Aug 22, 2020 at 7:59
  • options.addArgument("--remote-debugging-port=9222") try this
    – PDHide
    Commented Aug 22, 2020 at 11:24

1 Answer 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 [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 :)

More details on my latest answer: XVFB on Jenkins connecting to wrong display. Display shows black screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.