Skip to content
Advertisement

Protractor / Jasmine timing out on headless chromium – Error: Timeout – Async callback

Hi all so I am trying to run headless chromium with protractor and jasmine. I have everything setup and working for both firefox and chrome with a head. When I run firefox headless it works… when I try running chromium headless it ends up timing out. Looking for some help to solve this problem.

The error I get is :

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

Now I’ve read a million article online and have tried increasing the timeout time and adding done into the function as well…

Here is my current code:

Conf.js – this has a bunch of added args and settings that I’ve found online. I’ve tried pretty much every variation and had no success..

  exports.config = {
    framework: 'jasmine2',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['spec.js'],
    allScriptsTimeout: 5000000,
    capabilities: {
        'directConnect': true,
        'browserName': 'chrome',
        "goog:chromeOptions": {
            args: ["--headless", "--remote-debugging-port=9222", "--verbose", "--disable-gpu", "--disable-web-security", "--window-size=800x600"],
            'binary': "/usr/bin/chromium-browser"
        }
    }
  };

Spec.js – straight off of their website with console.logs. All of the console.logs print out in the following order 3,1,2. This is something I’m unsure is correct? Should the describe be waiting for the it to finish? It almost feels like my it is never returning…

    describe('angularjs homepage todo list', function() {
  it('should add a todo', function(done) {
    console.log("WOOO1");
    browser.get('https://angularjs.org');

    element(by.model('todoList.todoText')).sendKeys('write first protractor test');
    element(by.css('[value="add"]')).click();

    var todoList = element.all(by.repeater('todo in todoList.todos'));
    expect(todoList.count()).toEqual(3);
    expect(todoList.get(2).getText()).toEqual('write first protractor test');

    // You wrote your first test, cross it off the list
    todoList.get(2).element(by.css('input')).click();
    var completedAmount = element.all(by.css('.done-true'));
    expect(completedAmount.count()).toEqual(2);
    console.log("WOO2");

  }, 15000);
  console.log("WOO3");
});

Following this some other discoveries I have found… when I go to the localhost:9222 I see

   Inspectable WebContents
data:text/html,<html></html>

The data:text/html,<html></html> is a link and if clicked on takes me to the remote chrome debugger that is loading … data:text/html,. This is where I think the problem is. Why is this never actually loading the angular site?

Maybe I’m off base but does anyone know how to make sense of this?

EDIT: Additional useful information. I am using chromium 79.0.3945.130 chromedriver 79.0.3945.36

jasmine v3.5.0 jasmine-core v3.5.0

Protractor 5.4.3

Thanks

Advertisement

Answer

Config that ended up working for me

 exports.config = {
    framework: 'jasmine',
    allScriptsTimeout: 9000,
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['spec.js'],

    capabilities: {
    'directConnect': true,
    'browserName': 'chrome',
    "goog:chromeOptions": {
    args: ["--headless", "--remote-debugging-port=9222", "--verbose", "--disable-gpu", "--disable-web-security", "--window-size=800x600"],
    'binary': "path to chrome"
    }
    }
    };
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement