In OSX, I have configured an Intellij 15 run/debug task as in this question:
How to debug angular protractor tests in WebStorm
It runs ok but debug doesn't work. It throws:
/usr/local/bin/node --debug-brk=60144 --nolazy /usr/local/lib/node_modules/protractor/lib/cli.js /Users/XXXX/Workspace/frontend-test/config.js
Debugger listening on port 60144
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Process finished with exit code 139
Any idea?
Thanks in advance.
Got it! Just add --harmony parameter to "Node parameters" in the Run/Debug Configuration window.
Related
When I issue the protractor command at the command line, with the following configuration:
'use strict';
// Protractor configuration
var config = {
specs: ['test/e2e/*spec.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;
I get this:
$ protractor
[12:22:23] I/launcher - Running 1 instances of WebDriver
[12:22:23] I/local - Starting selenium standalone server...
[12:22:24] I/local - Selenium standalone server started at http://10.0.0.242:55414/wd/hub
Started
.
1 spec, 0 failures
Finished in 8.223 seconds
[12:22:33] I/local - Shutting down selenium standalone server.
[12:22:33] I/launcher - 0 instance(s) of WebDriver still running
[12:22:33] I/launcher - chrome #01 passed
the problem is that it takes 5+ seconds to start up the "selenium standalone server".
Two questions - (1) do I need this server to run the tests? And (2), is there a way to run the server in the background without having to restart the server everytime?
You also use selenium server jar in the protractor configuration. Checkout the sample bellow. this also comes in handy while using phantojs.
seleniumServerJar: '../utils/selenium-server-standalone-2.53.1.jar',
seleniumPort: 4444,
make user seleniumAddress is commented in the config
Do you use the protractor DirectConnect option? If so, you can also use the standalone webdriver-manager. Protractor also uses it as a dependency.
For local development I installed it as a global with npm install webdriver-manager -g, then update it with webdriver-manager update and start it with webdriver-manager start. It will then run on the background on the default port 4444, run webdriver-manager to see all the options.
You then don't need to start the webdriver for each test / suite.
Hope it helps
I am new to protractor. I am getting the following error while trying to run Selenium tests using protractor
I/hosted - Using the selenium server at http://localhost:4444/wd/hub
I/launcher - Running 1 instances of WebDriver
E/launcher - Error code: 135
E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
at ClientRequest.<anonymous> (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:381:15)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:267:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1269:8)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
From: Task: WebDriver.createSession()
at Function.createSession (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:329:24)
at Builder.build (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:458:24)
at Hosted.DriverProvider.getNewDriver (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:37:33)
at Runner.createBrowser (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\built\runner.js:187:43)
at c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\built\runner.js:261:30
at _fulfilled (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
at runSingle (c:\Users\SavDevService.SAVISIONLAB\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:137:13)
E/launcher - Process exited with error code 135
I checked to see if any other process is listening to port 4444, but did not find any. also I am running web driver with --standalone flag.
It seems like selenium server is not running on http://127.0.0.1:4444/wd/hub. Before running your protractor test,you must start the selenium server using below command.webdriver-manager start. After starting the server your tests will execute without any errors.
If you dont want to start selenium server manually,then just remove seleniumAddress:http://localhost:4444/wd/hub property from your conf.js.
You can also add these lines to your conf.js file:
chromeOnly: true,
directConnect: true,
Start the webdriver, its good to update the web driver and start the web driver before you start executing your automation test suite by executing the below commands in console screen.
webdriver-manager update
webdriver-manager start
Do you have selenium drivers installed for the browser you want to test with?
Try with
webdriver-manager update
It will take care of installing the drivers for you. You just need to run it once, if you call it again it will see that the drivers are already installed and will not procede.
Did you start selenium server using this command webdriver-manager start?
If not there might be a problem with your configuration with selenium server.
I would suggest follow this thread
Solution 1
try webdriver-manager update --standalone
Solution 2
Remove previous instance (.jar file) of web driver from the location- C:\Users\HP\AppData\Roaming\npm\node_modules\p rotractor\selenium
Download the selenium-server-standalone-2.45.0 from http://www.seleniumhq.org/download/ and replace the .jar file.
i also get this type of error, but after set environment variables this issue is solved.
location of the npm;
Example:
C:\Users\AppData\Roaming\npm
The directConnect solution is nice when running protractor locally, but it didn't work when trying to do it on Jenkins. It seems like when running everything in Docker containers in Jenkins, you'll have to start webdriver-manager start in detached mode -d first, wait, and then start protractor.
check your web driver status by the below command
webdriver-manager status
if it's not up to date you can remove and install it by following these steps
webdriver-manager clean
webdriver-manager status
webdriver-manager update
webdriver-manager start
then start your web driver by
if you get this error
ERROR [BaseServer.start] - Port 4444 is busy, please choose a free port and specify it using -port option
you can set another port by this command(for example port 4545)
webdriver-manager start --seleniumPort 4545
then your selenium web driver will run
I have run the windows command prompt as administrator and solved this problem. I am not seeing this problem anymore.
And I added also
chromeOnly: true,
directConnect: true,
Problem
I'm trying to get AppVeyor running some e2e tests using Protractor and Selenium-webdriver.
Everything works fine on my local machine, but when building and testing on AppVeyor protractor exits with code 1 due to a not-found method in the selenium-webdriver, it seems. I have tried to get some information on the error message, but my search didn't get me anywhere. Most of the result come from backend testing with Java.
Here is a snippet of the buildlog:
node_modules\.bin\gulp protractor
[08:37:23] Using gulpfile C:\projects\kitos\gulpfile.js
[08:37:23] Starting 'protractor'...
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://10.240.0.18:63619/wd/hub
..
Finished in 42.225 seconds
2 tests, 2 assertions, 0 failures
C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108
var template = new Error(this.message);
^
UnknownError: Can't obtain updateLastError method for class com.sun.jna.Native
at new bot.Error (C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
at Object.bot.response.checkResponse (C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
at C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
at [object Object].promise.ControlFlow.runInFrame_ (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at [object Object].goog.defineClass.notify (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at [object Object].promise.Promise.notify_ (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at [object Object].promise.Promise.notifyAll_ (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15)
at process._tickCallback (node.js:368:9)
[launcher] Process exited with error code 1
[08:38:13] 'protractor' errored after 50 s
[08:38:13] Error in plugin 'gulp-protractor'
Message:
protractor exited with code 1
The selenium server is running, tests passes but when the server is about to shut down the error occurs.
Setup
On build start I run npm install which in turn runs node_modules\\.bin\\webdriver-manager update --standalone as a postinstall script.
Protractor is run with a gulp task with the gulp-protractor plugin and the selenium standalone jar is defined in the protractor configuration as seen here:
exports.config = {
seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',
specs: ['Tests/**/*e2e.spec.js'],
resultJsonOutputFile: 'results-protractor.json',
allScriptsTimeout: 30000
};
The complete buildlog can be seen here: https://ci.appveyor.com/project/Crevil/kitos/build/1.0.187
Apologizing for the noisy log. The deployment logging is very loud in the console and it is not configurable on AppVeyor afaict.
Local log information
As mentioned, everything runs fine on my local machine. Here is a log of protractor running.
C:\Users\BSO\Documents\Git repos\kitos>gulp protractor
[09:54:58] Using gulpfile ~\Documents\Git repos\kitos\gulpfile.js
[09:54:58] Starting 'protractor'...
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.5.153:16772/wd/hub
..
Finished in 5.241 seconds
2 tests, 2 assertions, 0 failures
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 passed
[09:55:08] Finished 'protractor' after 10 s
C:\Users\BSO\Documents\Git repos\kitos>
This issue is solve with the following parameter to the java runtime engine
localSeleniumStandaloneOpts: {
args: ['-Djna.nosys=true']
},
...
There are more details in the protractor issue here and the specific solution by Feodor Fitsner.
I'm bringing this into discussion here, since I had started this conversation over GithubIssue 2630, Basically I'm having problems with the integration of Protractor and Cucumber, I had even tried to downgrade to a older versions for both but the same thing happens, here's an explanation of what I did so far:
I had uninstalled everything and started from scratch. I started by installing Protractor, Cucumber and Webdriver globally and I can see this error, same as before, when I run the protractor command.
$ protractor conf.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.104:64737/wd/hub
[launcher] Error: TypeError: undefined is not a function
at /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:150:36
at Function.promise (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:650:9)
at /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:147:14
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:525:49
at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:355:11)
[launcher] Process exited with error code 100
```
Then I've installed all locally, running npm install, and I got this error
[launcher] Process exited with error code 1
/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/node_modules/q/q.js:126
throw e;
^
Error: No selenium server jar found at the specified location (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar). Check that the version number is up to date.
at LocalDriverProvider.addDefaultBinaryLocs_ (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/lib/driverProviders/local.js:37:11)
at LocalDriverProvider.setupEnv (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/lib/driverProviders/local.js:71:8)
at Runner.run (/Users/brunosoko/Documents/Dev/Personal/olapic-test2/node_modules/protractor/lib/runner.js:261:31)
at TaskRunner.run (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/lib/taskRunner.js:123:19)
at createNextTaskRunner (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/lib/launcher.js:223:20)
at /Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/lib/launcher.js:246:7
at _fulfilled (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/node_modules/q/q.js:759:13)
at /Users/brunosoko/Documents/Dev/Personal/test2/node_modules/protractor/node_modules/q/q.js:573:44
Which I resolved by installing locally webdriver ./node_modules/.bin/webdriver-manager update
Then I ran ./node_modules/.bin/protractor conf.js and I'm getting the same error as above, for cucumber.js:150:36
Later, I tried to uninstall globally framework, npm uninstall -g protractor and npm uninstall -g cucumber
But the same error happens! I'm not sure what am I doing wrong!
I'm not sure what is wrong with your specific situation, but I have created a bare minimum example of cucumber 0.8.1 working with the yet to be released version of protractor here - https://github.com/darrinholst/protractor-cucumber-example. Hope this helps.
git clone https://github.com/darrinholst/protractor-cucumber-example
cd protractor-cucumber-example
npm install
npm test
I'm trying to learn AngularJS. As part of this, I want to learn to use end-to-end testing. Currently, I have a directory structure like this:
node_modules
.bin
...
protractor
...
node_modules
.bin
adam-zip
glob
minijasminenode
optimist
saucelabs
selenium-webdriver
protractor
config.js
src
tests
test.e2e.js
My config.js file looks like the following:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: [
'../src/tests/test.e2e.js'
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
test.e2e.js looks like the following:
'use strict';
describe('My Sample', function () {
driver = protractor.getInstance();
beforeEach(function () {
driver.get('#/');
});
it('My First Test', function () {
message = "Hello.";
expect(message).toEqual('World.');
});
});
When I attempt to run my end-to-end tests using protractor, I run the following command from the command-line:
node_modules\.bin\protractor protractor\config.js
When I run that command, I receive the following error:
C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1542
throw error;
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:12
7:16)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1528:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriv
er\lib\webdriver\webdriver.js:130:49)
at Function.webdriver.WebDriver.createSession (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver
\lib\webdriver\webdriver.js:110:30)
at Builder.build (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\builder.js:105:20)
at runJasmineTests (C:\Src\MyProject\node_modules\protractor\lib\runner.js:191:45)
at C:\Src\MyProject\node_modules\protractor\lib\runner.js:255:5
at C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriv
er\lib\webdriver\promise.js:1438:20)
at notify (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:328:12)
at then (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:377:7)
What am I doing wrong?
I solved this with --standalone flag:
webdriver-manager start --standalone
I got it working by removing the following line from my config.js
seleniumAddress: 'http://localhost:4444/wd/hub',
Are you running a selenium server? The git README states the following:
WebdriverJS does not natively include the selenium server - you must start a standalone selenium server. All you need is the latest selenium-server-standalone.
source: https://github.com/angular/protractor
The error message is due to the following:
[ECONNREFUSED] The attempt to connect was ignored (because the target is not listening for connections) or explicitly rejected.
Check the URL of the Webdriver manager. The default URL is:
http://localhost:4444/wd/hub
Use a background process to run the webdriver-manager, then run protractor:
Start-Process webdriver-manager start -passthru
protractor conf.js
This will start up a Selenium Server and will output a bunch of info logs. Your Protractor test will send requests to this server to control a local browser. Leave this server running
References
Protractor Tutorial
Protractor Docs: Config File Reference
CONNECT Man Page
POSIX Man Page
For me, this had happened due to incompatible versions of Node and Protractor.
My fix-
Update Node to latest version (v7.0.0 in my case)
Follow steps given here https://stackoverflow.com/a/19333717/1902831
Install latest protractor version (4.0.10 in my case) using:
npm install -g protractor
Open another terminal and execute these command:
webdriver-manager update
webdriver-manager start
Run tests in another terminal using:
protractor conf.js
If you are using the npm protractor-webdriver grunt plugin (https://www.npmjs.org/package/grunt-protractor-webdriver) you may exeprience same kind of error.
This is due to webdriver termination just before test ends. The test runs successfully and then you have a message like :
Session deleted: Going to shut down the Selenium server
Shutting down Selenium server: http://127.0.0.1:4444
Shut down Selenium server: http://127.0.0.1:4444 (OKOK)
d:\Projets\Clouderial\nodeProjects\cld-apps\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (d:\Projets\Clouderial\nodeProjects\cld-apps\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
I resolve this using the keepAlive option in the grunt plugin.
Here is my Gruntfile.js config :
protractor_webdriver: {
options: {
keepAlive : true // True to keep the webdriver alive
},
start: {
},
},
...
I hope this will help someone.
JM.
I also faced the same problem,the trick that worked for me is to use two cmd windows,keeping the one open after typing webdriver-manager start and without pressing enter key(if enter key is pressed the selenium server is shutdown,don't know why) open another cmd window and call your tests.
#Alexandros Spyropoulos, it took me quite some time to figure out how to run protractor and I think we had the same problem. You should open one terminal tab and run webdriver-manager start --standalone. Then open another terminal tag and run protractor ***.conf.js
In the hopes that it might help someone: I'd been having the same problem - encountering ECONNREFUSED using grunt-protractor-runner. The nuance to my case is that I was running my entire E2E environment (test files, web application and entire backend) within a Docker container.
I tried running protractor
with and without additional grunt-protractor-webdriver task to get webdriver up and running 'manually' (no difference);
with and without enabling directConnect and keepAlive settings (bypassing Selenium and resulting in crashes related to Chromedriver, one of which was described here).
The solution was rather simple: increase the amount of memory allocated to the container. On my Windows 10 host machine, I performed the following steps:
Run VBoxManage.exe modifyvm default --memory 8192 (via custom shell script) before starting the docker-machine (via Docker Quickstart script, which is equivalent to docker-machine start). (Thanks to this SO answer).
Changing my shell script to run my default container, adding the --shm-size=4G argument to my docker run command. (See docs)
You can verify if it worked by running df -h in your guest machine, by checking the amount of memory mounted on /dev/shm.
As a result, I no longer have seemingly inexplicable errors such as ECONNREFUSED.
If you run the provided protractor demo, you should try running the protractor config in the same command prompt as selenium. Try running both selenium server and protractor separately.
Make Sure first selenium runs by following command.
webdriver-manager start --standalone
And run the protractor in a separate command window.
protractor conf.js
(In my case conf.js was the config file )
I faced a similar issue to the one #David Remie faced with the Selenium Docker grid/standalone. With minimal RAM/CPU, the tests would start before the webdriver was up. A less resource consuming approach is to wait a few seconds before testing (run 'sleep 5' or something like that).
Increasing RAM was sometimes enough as a workaround for the issue, but the real problem was that the Selenium CMD (/opt/bin/entry_point.sh, starts a supervisor that runs the webdriver) from the image based on https://hub.docker.com/r/selenium/node-base/dockerfile was taking time to start the Selenium webdriver.
webdriver-manager start ----- didn't help, But below one helped
webdriver-manager start --standalone