2

I have developed BDD cucumber test framework using Selenium and Java. Our dev ops uses GOCD as CI CD tool so I need to integrate framework with GOCD. I have integrated selenium framework with Jenkins numerous times but its my first time with GOCD. I have tried to look for plugin but didnt find any and neither any assistance with blogs or any support.

Is there any way that I can integrate selenium framework with GOCD so that it can be used in pipeline?

Ricky
  • 73
  • 1
  • 12

1 Answers1

0

Basically you need to have program you can run at the command line that GoCD can call for you as part of a test task/job/stage.

Then you need a GoCD agent with all the necessary software installed, and run that command. (Or have a docker image with all the necessary software, and run the tests in that command).

One common problem is that selenium automates browsers, and browsers tend to want to have a display environment, and GoCD tends to run on servers without any GUI.

On Linux, there's a tool called Xvfb that provides a virtual X server which tricks the browser into thinking there is a GUI.

This is a small bash script that we run before starting the Selenium tests:

#!/bin/bash

DISPLAY=":99"

# The last one wins
killall -q Xvfb

# Start virtual x-server.
Xvfb -ac :99 -screen 0 1280x1024x16 > x11.log 2>&1 &
XSERVER_PID=$!
sleep 5
kill -0 $XSERVER_PID
if [ $? -gt 0 ]; then
    echo "cannot start Xvfb"
    exit 1
fi

# Start VNC server for watching the test runs and debugging problems.
x11vnc --listen 0.0.0.0 -rfbport 5900 -display :99 -forever >> x11.log 2>&1 &
export DISPLAY=:99

# Window manager for enabling resize of browser window.
fvwm >> x11.log 2>&1 &

Note that this also starts a lightweight window manager (fvwm) to enable tests that resize browser windows.

moritz
  • 12,710
  • 1
  • 41
  • 63
  • Thanks for replying... does this mean that I should hv chosen other automation test tool?? If yes then which toool do you reccomend??? Or will I be facing this issue with any automation test tool?? – Ricky Jun 12 '19 at 19:05
  • I don't think you would be better off with a different tool, but my experience is not extensive. – moritz Jun 13 '19 at 20:39
  • The start of the answer of mortiz is right : have a script launching your selenium command, and configure goCD to call it. But for some time now, Selenium can be used without display at all with headless webdriver. No need to run a display server. – TonyMoutaux Aug 07 '19 at 13:57