3

I am working on an AngularJS app, and am looking to add some automated testing to the development life cycle of the project.

After doing a bit of research, and asking on here about what frameworks would be best to use to enable the testing functionality that I require, I have decided to use Protractor as the testing framework for my app.

I am following the tutorial to try and get Protractor up and running with my application (i.e. with my existing app, not the Super Calculator application that the tutorial references), but am encountering a problem:

The way my development environment is set up, is that I am doing all of the development of the AngularJS app on my local Windows machine, and using a Unix VM (running CentOS) to serve my app's front-end using grunt.

I have run through the setup steps in the tutorial, and have all of that set up correctly. However, on Step 0, after creating the spec.js & conf.js files as instructed, when I then run:

protractor conf.js

in the command line, I get the following output:

[16:18:39] I/launcher - Running 1 instances of WebDriver

[16:18:39] I/hosted - Using the selenium server at http://localhost:4444/wd/hub

[16:18:40] E/launcher - Error code: 135

[16:18:40] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444

[16:18:40] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 at ClientRequest. (C:\Users\Elgan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:238:15) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at Socket.socketErrorListener (_http_client.js:310:9) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1277:8) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)

From: Task: WebDriver.createSession() at Function.createSession (C:\Users...\webdriver.js:777:24) at Function.createSession (C:\Users...\chrome.js:709:29) at createDriver (C:\Users...\index.js:167:33) at Builder.build (C:\Users...\index.js:623:16) at Hosted.getNewDriver (C:\Users...\driverProvider.ts:60:29) at Runner.createBrowser (C:\Users...\runner.ts:225:39) at q.then.then (C:\Users...\runner.ts:391:27) at _fulfilled (C:\Users...\q.js:834:54) at self.promiseDispatch.done (C:\Users...\q.js:863:30) at Promise.promise.promiseDispatch (C:\Users...\q.js:796:13)

[16:18:40] E/launcher - Process exited with error code 135

My guess is that this is happening because of the address/ port I'm using when running it (i.e. the address/ port used on the VM)?

Would that be the case? If so, what IP address/ port should I be using? The port that I have Karma set up on is: 9876- should I be using this port, rather than the one from the tutorial (4444)? Or if not, how can I resolve this issue?

Edit

When running webdriver-manager start, the console shows the following output:

[16:59:26] I/start - java -Dwebdriver.chrome.driver=C:\Users...\chromedriver_2.32.exe -Dwebdriver.gecko.driver=C:\Users...\geckodriver-v0.19.0.exe -jar C:\Users...\selenium-server-standalone-3.5.3.jar -port 4444

[16:59:26] I/start - seleniumProcess.pid: 11464 'java' is not recognized as an internal or external command, operable program or batch file. [16:59:27] I/start - Selenium Standalone has exited with code 1

1 Answer 1

3

With the default config suggested in the tutorial, Protractor expects a selenium server at the 127.0.0.1:4444 address. And, I suspect, you have not started a selenium server.

So, one way to approach it would be to use webdriver-manager package to start a local selenium server as suggested in the Setup section of the tutorial:

webdriver-manager start

And leave it open. Then, run protractor from a different command-line.

Another option would be to directly interact with the browser without a selenium server. Currently you can only do that with Chrome and Firefox only. Set the directConnect to true in your config and remove the seleniumAddress configuration parameter.

4
  • Thanks for your answer. When I run webdriver-manager start, I get some output that seems to be complaining that 'java' is not recognised as an internal or external command, operable program or batch file...? I'll update my OP to show the full message now. Sep 20, 2017 at 16:01
  • @someone2088 I guess this is your problem stackoverflow.com/questions/15796855/…. Give it a try, thanks.
    – alecxe
    Sep 20, 2017 at 16:05
  • Thanks for the link. So I've configured my environment variables, but now when I run webdriver-manager start again, I get quite a lot of error output in the console, the last four lines of which are: Unrecognized option: -port, Error: Could not create the Java Virtual Machine., Error: A fatal exception has occurred. Program will exit. & I/start - Selenium Standalone has exited with code 1... The port being used is 4444 & the seleniumProcess.pid is 5507. Any suggestions as to why I'm getting this, and how I can fix it? Sep 21, 2017 at 9:20
  • Ah, it seems that error was because I had forgotten to become root before running the command Sep 21, 2017 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.