How to run protractor test cases in headless mode using xvfb.

In recent times I am getting lot questions on how to automate protractor test cases using xvfb in jenkins and that's the reason why I'm creating this post. To start with Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. Xvfb performs all graphical operations in memory without showing any screen output. Let us assume that if you want to run automation cases in any server machine that doesn't have any display option, then we can use Xvfb to create a virtual display that can be used by the browser window to launch the web application. If you are using ubuntu based OS, then installing Xvfb is a very straight forward process. Just execute the below shell commands in terminal to install Xvfb and all its dependencies.

sudo apt-get update

sudo apt-get install -y xvfb

sudo apt-get install -y  xfonts-100dpi xfonts-75dpi xfonts-cyrillic  dbus-x11

To download and install google chrome, run the below commands.

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i google-chrome*.deb

That's it. Now Xvfb and google chrome will be installed successfully. In next step I will explain how the protractor process can be started using Xvfb display.

xvfb-run -a -e /dev/stdout -s "-screen 0 2920x2580x24" node node_modules/protractor/bin/protractor configuration.js?

The above command will start protractor using Xvfb display and launches chrome browser in headless mode. You can also set the display screen size using -s flag.

Hope this post is informative! Reach me out in case of any queries!

Suresh Salloju

Founder | Optimworks Technologies Private Limited

7 年

Nice post sudharsan selvaraj

要查看或添加评论,请登录

Sudharsan Selvaraj的更多文章

  • Take full page screenshot using protractor.

    Take full page screenshot using protractor.

    When comes to test automation, screenshots plays a crucial role in debugging the failures. In most of the scenarios…

  • API automation is now made simple with protractor.

    API automation is now made simple with protractor.

    End-to-End (e2e) tests are much harder to write than unit tests, because they rely on many different parts of your…

    15 条评论
  • Identify css regressions as part of protractor automation

    Identify css regressions as part of protractor automation

    We got a special requirement to implement any framework that helps us in identifying css issues as part of functional…

    1 条评论
  • Parallel test execution in protractor

    Parallel test execution in protractor

    In this post, I will explain how to split and run all the specs in different browser instances using protractor. Hope…

    10 条评论

社区洞察

其他会员也浏览了