Angularjs Protractor – Selenium headless End to End Testing

This post assumes that you know about protractor.

Scenario:

To setup the end to end testing in the server for continuous integration in Ubuntu.

Selenium Headless server installation:

  • Open the following ports 4444, 7054,5055 [If your continuous integration server is different from selenium server]
  • Install Xvfb [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.]
sudo aptitude install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xvfb x11-apps
  • Install imagemagick(to take screenshot), google-chrome and firefox
sudo aptitude imagemagick firefox google-chrome-stable
  • Now run the Xvfb server
/usr/bin/Xvfb :99 -ac -screen 0 1024x768x24 &
  • To make the x-windows apps to connect this Xvfb server,
export DISPLAY=:99
  • Now run the selenium server. When it launches the google-chrome or firefox , it will use the xvfb server.
node_modules/protractor/bin/webdriver-manager start

Debugging the selenium headless server installation:

  • First check whether the browsers are using the Xvfb, when your run in the command line. [when you run the command firefox, it will just throw some output and waits till you kill with ctl+C]
  • then, Check whether selenium works or not, by visiting the the following URL
http://<your_selenium_server>:4444/wd/hub/static/resource/hub.html

Selenium server

  1. You can try to create session with different browsers.
  2. Click load script and enter some URL.
  3. Take screenshot, you should see the loaded page screenshot.

Configure protractor:

With the following

seleniumAddress: 'http://<Your_selenium_server_address>:4444/wd/hub'
This entry was posted in AngularJS, Javascript, testing. Bookmark the permalink.

2 Responses to Angularjs Protractor – Selenium headless End to End Testing

Leave a Reply

Your email address will not be published. Required fields are marked *