How do I run my protractor script in Gitlab CI when I need to access a dockerized Angular Application locally*

I’m new to protractor and CI and would like to ask for your help.
I have a docker image running for my testing application.
I also have a docker image as my selenium hub using the code below: (I’ve also ran selenium docker without Java_opts line)

docker run -d -p 4444:4444 -p 5900:5900 -e JAVA_OPTS="-Dwebdriver.chrome.whitelistedIps=" --shm-size="2g" selenium/standalone-chrome-debug

I am able to run my protractor tests locally or through vncviewer (port 5900), however, I am not able to do so when I run it through pipeline. I’m always stuck at:

[02:32:15] I/launcher - Running 1 instances of WebDriver
[02:32:15] I/hosted - Using the selenium server at http://selenium-standalone-chrome:4444/wd/hub

Then, a timeout error will display:

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

Below is my yml and conf file, I have made it simple so I could just see if I could open my docker image (login) on gitlab pipeline.

gitlab yml file:

image: node:12.15 

variables:
 GIT_SSL_NO_VERIFY: "true"

services:
    - selenium/standalone-chrome

test:
    script:
        - npm install
        - npm test

conf.js file

exports.config = {
  
  seleniumAddress: 'http://--ipaddresshere--:4444/wd/hub', 
 // or http://selenium-standalone-chrome:4444/wd/hub (both same error in CI)

  capabilities: {
    'browserName': 'chrome'
  },
  framework: 'jasmine',

  specs: ['feature2.js'],
}

feature2.js

describe('Login',function(){
    it('Login', function () {
    browser.waitForAngularEnabled(false); // (I disabled/enabled this and error still persist)
    browser.driver.get('http://<ipaddresshere>:3030/login');
    });
});

Even with this simple code, I am still unable to open the login page. I’ve already tried passing chromeoptions such headless, no sandbox, etc., tried different node version, tried jasminetimeout/allscriptimeout, installed selenium 4 version as hub, updated selenium webdriver, updated webdriver-manager and a lot more.

I’ve tried running the code using browser.get(‘http://google.com’) and I’m able to access the site. I’m assuming my setup doesn’t allow me to access the local docker application.
I really need your help if there’s something I’ve missed. Or if you have other suggestions on how to access the local docker application in gitlab pipeline aside from selenium hub, I would greatly appreciate it. Thank you!

I hope someone can shed light to my question here. Thank you!

If you can run the pipeline in containers locally, and it fails on GitLab, I would suggest opening an issue in GitLab. Or maybe there are some limitations for GitLab runners. which are covered in docs.

Or try to isolate the problem to some hello world containers that do not use protractor at all. Then more people without experience in Angular and its testing specific would be able to help.

Sorry if I wasn’t clear, I don’t have a local gitlab runner installed and I’m using a shared runner instead. What I meant was, I’m able to run my script using my selenium docker and view it on vnc viewer locally. However, once I push my files in gitlab, the job will fail in pipeline.

Great suggestion, I’ll do just that and maybe I can find a solution to this. Thank you!

1 Like