Search code examples
selenium-webdriverprotractorwebdriver-manager

Getting ETIMEDOUT error when running protractor conf.js


I am a beginner in protractor. I did the installations necessary for running protractor. When tried running the sample script mentioned in the protractor documentation, i am getting ETIMEDOUT error. and the url points to 127.0.0.1:4444. The same url is not accessible manually also. But when trying http://localhost:4444/wd/hub, page opens properly. I am not sure why the conf.js trying to access the 127.0.0.1:4444, even if i give the 'seleniumAddress' parameter to 'http://localhost:4444/wd/hub'. Please help me guys to resolve this issue

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js']
};

describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {
    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);
  });
});


Solution

  • I agree with the other responses. http://localhost:4444/wd/hub is the same as http://127.0.0.1:4444/wd/hub. Usually this is defined in your /etc/hosts file.

    Since I imagine you are just trying to run your Protractor tests, as long as you've downloaded the binaries with webdriver-manager update, you could do one of the two options:

    1. Set directConnect: true (and remove seleniumAddress. This is available for chrome or firefox (version 47*) without the selenium standalone server.
    2. Remove seleniumAddress all together. Protractor will launch the selenium standalone server for you before the test and then tear it down when the test is over.

    Note: for the above to work, webdriver-manager update should run from the project directory to download the binaries to the correct directory. Something like node node_modules/.bin/webdriver-manager update or ./node_modules/.bin/webdriver-manager update should download the driver binaries to node_modules/protractor/node_modules/webdriver-manager/selenium.

    • So why Firefox 47, currently newer versions are not supported. We are currently testing Firefox 48+ but there are still a few outstanding issues.