Xvfb plugin for Jenkins

Problem: Error while running Selenium tests via Jenkins on a Ubuntu machine.

WebDriverException(“The browser appears to have exited “
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

Error


Why this post?

We faced this issue when we were trying to run our Selenium tests using Jenkins on an Ubuntu system. The same tests were working fine when we ran it through the terminal. We figured out that this was probably because Jenkins user did not have access to the appropriate display.

We solved the issue at first by making changes to the Jenkins start script. You can refer to this link for details. Then the client suggested (thanks, Prashanth!) using Xvfb. In rest of the post we will explain in detail how we solved this issue using Xvfb.


1. Xvfb installation:
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.
Make sure you have Xvfb installed in your Ubuntu system if not Install xvfb in ubuntu using below code

sudo apt-get install xvfb


2. Install Xvfb Plugin for Jenkins:

Xvfb Plugin for jenkins lets you control Xvfb virtual frame buffer X11 server with each build. It starts Xvfb before the build starts, and stops it with the build.
Xvfb plugin


3. Configure Jenkins:
Start by going to Manage Jenkins / Configure System and setup your Xvfb installation. You need to give it a arbitrary name like default Xvfb and directory in which the Xvfb executable is located. Eg:/usr/bin.

Jenkins Configuration


4. Project Configuration:
On the job configuration page, enable the “Start Xvfb before the build, and shut it down after.” under the Build Environment. In case need you can customize defaults by clicking on Advanced… button.

Project Configuration


5. Re-running the test:
After making the above changes the test ran fine. Note that the plugin starts Xvfb before the build starts, and stops it with the build
Rerun the Jenkins test


Well, that was cool. As always, we are happy to answer any questions you may have.


A weekly newsletter for testers


View a sample



Avinash Shetty
I am a software tester with over 10 years of experience in software testing. Currently I am working at Qxf2 Services Bangalore. As a student of the context-driven approach to software testing I feel there is a lot to learn out there which keeps me very excited. My work has helped me gain good experience in different areas of testing like CRM, Web, Mobile and Database testing. I have good knowledge of building test scripts using Automation tools like Selenium and Appium using Java and Python. Beside testing I am a “Sports Fanatic” and love watching and playing sports.

© 2013-2017, Avinash Shetty. All rights reserved.

8 Comments

  1. Anonymous said:

    Hi, I am facing the same issue, but unable to resolve the problem on following the steps you mentioned. I added the plugin on the jenkins and installed xvfb on the jenkins machine as well.

    November 25, 2015
    Reply
    • I’ll take a shot in the dark. Can you make sure that the path for your xvfb executable is correct in Step 3? To find your xvfb executable, type in ‘which xvfb’ on your command prompt.

      If the path to your xvfb executable is set correctly, can you post the Jenkins console output?

      November 30, 2015
      Reply
      • Anonymous said:

        Hi, Could you please elaborate. I am not getting ,in which directory is that xvfb executable. And unable to set directory path while installing xvfb. Thanks in Advance.

        April 26, 2016
        Reply
        • Avinash Shetty Avinash Shetty said:

          If you have installed xvfb in your machine and if you run ‘which xvfb’ on your command prompt, you should see the path where xvfb is installed.

          April 29, 2016
          Reply
  2. susant said:

    Great article, Put me into the correct path.
    xvnc plugin is not working properly in mac slaves and was struggling a bit..and the find the solution with xvfb

    March 18, 2016
    Reply
  3. Meghraj said:

    Good one

    October 25, 2016
    Reply
  4. Jithin Mathew said:

    Getting an error while running test on jenkins

    Xlib: extension “RANDR” missing on display “:51”.
    Xlib: extension “RANDR” missing on display “:51”.

    February 27, 2017
    Reply

Leave a Reply

Your email address will not be published.