1
votes

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);
  });
});
3
localhost is nothing but it denotes the ip address 127.0.0.1.before executing the protractor test, enter the following command sudo webdriver-manager update && webdriver-manager start in a new terminal window and then execute protractor conf.jsSudharsan Selvaraj

3 Answers

2
votes

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.
1
votes

You need 2 terminal for this.

  1. In first terminal, run below command: webdriver-manager start this will create a server for node/client to access(that you have added in seleniumAddress)

  2. In second terminal, run below command: protractor conf.js This will start your script, by using server created at http://localhost:4444/wd/hub.

And localhost is same as 127.0.0.1.

0
votes

If localhost is not the same as 127.0.0.1 it sounds like your hosts files has been played around with or some more nefarious networking issue. I do not feel we have enough information to correctly debug why you are having this issue but I would like to suggest a workaround. Why not use your actual local internal IPv4 address?

To get a list of your IPv4 addresses in Windows type

ipconfig | findstr /R /C:"IPv4 Address"

To get a list of your IPv4 addresses in Linux type

hostname -i

To get your IPv4 address on a Mac type

ifconfig |grep inet

The address on mac should be located on the last line between inet and netmask

Your config file should look something like this after

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