protractor sets error without opening browser - protractor

i download a new ionic project and i am trying to test the header contains these elements ""
my config file is
exports.config = {
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['../www/head.spec.js'],
multiCapabilities: [
{
browserName: 'chrome'
}]
}
named this as e2e.js
my test case file is
describe('header Module', function(){
var header;
beforeEach(function() {
header = element(by.css('title'));
});
it('should check title text',function(){
expect(header.getText()).toContain('Ionic Blank Starter');
});
});
and i named this as head.spec.js
my issue is that i could see the browser opened and my protractor sends an error msg
empresss-Mac-mini:myApp admin$ protractor test/e2e.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
at ClientRequest. (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172:16)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at doNTCallback2 (node.js:439:9)
at process.tickCallback (node.js:353:17)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at [object Object].Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
at [object Object].DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at [object Object].Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:182:37)
at /usr/local/lib/node_modules/protractor/lib/runner.js:263:21
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
[launcher] Process exited with error code 1
could someone help to fix this issue
when i try to webdriver-manager update err msg is displayed
empresss-Mac-mini:~ admin$ webdriver-manager update
fs.js:799
return binding.mkdir(pathModule._makeLong(path),
^
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/protractor/selenium'
at Error (native)
at Object.fs.mkdirSync (fs.js:799:18)
at Object.<anonymous> (/usr/local/lib/node_modules/protractor/bin/webdriver-manager:126:6)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:134:18)
at node.js:961:3
empresss-Mac-mini:~ admin$

Related

The element to find the link does not work instead browser.driver.findElement works

The login page of my app is not built with angular, but after the login, the pages that its lands and remaining app is built with angularjs.
To get the url I used browser.driver.get('//appurl'); which works fine.
After the login, element(by.css('a[href="#!/test"]')).click(); does not work, where as browser.driver.findElement(by.css('a[href="#!/test"]')).click(); worked !!
Below is the error
ScriptTimeoutError: script timeout: result was not received in 11
seconds
(Session info: chrome...
(Driver info: ...,...)
at Object.checkLegacyResponse (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: Protractor.waitForAngular() - Locator: By(css selector, a[href="#!/workpieces"])
at thenableWebDriverProxy.schedule (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at ProtractorBrowser.executeAsyncScript_ (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\built\browser.js:425:28)
at angularAppRoot.then (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\built\browser.js:456:33)
at ManagedPromise.invokeCallback_
(C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction_ (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as click] (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\built\element.js:91:29)
at ElementFinder.(anonymous function).args [as click] (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\built\element.js:831:22)
at UserContext. (C:\Users\testuser\repos\test\spec.js:21:53)
at C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:112:25
at new ManagedPromise (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7)
at ControlFlow.promise (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12)
at schedulerExecute (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:95:18)
at TaskQueue.execute_ (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
From: Task: Run it("Test") in control flow
at UserContext. (C:\Users\testuser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:19)
From asynchronous test:
Error
at Suite. (C:\Users\testuser\repos\test\spec.js:20:5)
at Object. (C:\Users\testuser\repos\test\spec.js:1:63)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)

Error: listen EADDRINUSE when using nodemon with babel 7

nodemon -v: 1.18.6
node -v: v11.2.0
Command: nodemon --exec babel-node lib/server.js
My app starts ok with the above command. When I change the source code, I expect the nodemon restart automatically. But I got the error Error: listen EADDRINUSE: address already in use :::3000.
Error details
[nodemon] starting `babel-node lib/server.js`
events.js:167
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1294:14)
at listenInCluster (net.js:1342:12)
at Server.listen (net.js:1429:7)
at Function.listen (/Users/longntran/Desktop/learning/pangara-web/node_modules/express/lib/application.js:618:24)
at Object.listen (/Users/longntran/Desktop/learning/pangara-web/lib/server.js:12:5)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Module._compile (/Users/longntran/Desktop/learning/pangara-web/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Object.newLoader [as .js] (/Users/longntran/Desktop/learning/pangara-web/node_modules/pirates/lib/index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:620:32)
Emitted 'error' event at:
at emitErrorNT (net.js:1321:8)
at internalTickCallback (internal/process/next_tick.js:72:19)
at process._tickCallback (internal/process/next_tick.js:47:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:778:11)
at Object.<anonymous> (/Users/longntran/Desktop/learning/pangara-web/node_modules/#babel/node/lib/_babel-node.js:224:23)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
Dependencies
"dependencies": {
"ejs": "^2.6.1",
"express": "^4.16.4",
"react": "^16.6.3",
"react-dom": "^16.6.3"
},
"devDependencies": {
"#babel/core": "^7.1.6",
"#babel/preset-env": "^7.1.6",
"#babel/preset-react": "^7.0.0",
"#babel/node": "^7.0.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"jest": "^23.6.0",
"nodemon": "^1.18.6",
"pm2": "^3.2.2",
"prettier": "1.15.2",
"regenerator-runtime": "^0.13.1",
"webpack": "^4.26.1",
"webpack-cli": "^3.1.2"
}
Note
I am using nodemon with babel 7. Please help me. Thank you guys
I found an interesting fix in this thread around adding a delay and kill process commands to your scripts.
"events": {
"restart": "fuser -k 5000/tcp ; fuser -k 3050/tcp" // change to whatever ports you're using.
}
And to add a delay to the nodemon command:
--delay 1500ms
https://github.com/remy/nodemon/issues/1316#issuecomment-387367160
I also noticed that if I hit save twice in my code editor in rapid succession, I get this error. However if I only hit save once, I see no problem.
I've found that completing a graceful server shutdown on any interruption allows nodemon to restart successfully (using Express):
// Run server
const PORT = process.env.PORT || 3000
const server = app.listen(PORT, () => {
console.log('[server] Started server');
});
// Graceful shutdown of server
process.on('SIGINT', () => {
console.log('\n[server] Shutting down...');
server.close();
process.exit();
});
process.on('SIGTERM', () => {
console.log('\n[server] Shutting down...');
server.close();
process.exit();
});
process.on('uncaughtException', () => {
console.log('\n[server] Shutting down...');
server.close();
process.exit();
});

could not find cucumber plugin for protractor test

i am brand new to protractor and did setup as per the instructions from the protractor website. When i try to run the protractor test with the a cucumber framework i always get "Error: Error: Cannot find module 'cucumber'". Any help on this? below are by configurations.
cucumber-conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
browserName:'chrome'
},
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [
'./cucumber/*.feature'
],
cucumberOpts: {
require: ['./cucumber/*.js'],
tags: [],
strict: true,
format: ["pretty"],
dryRun: false,
compiler: []
},
onPrepare: function () {
browser.manage().window().maximize();
}
};
when i run protractor cucumber-conf.js i get below error.
/opt/protractor_tests
➔ protractor cucumber-conf.js
(node:5681) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[12:06:55] I/launcher - Running 1 instances of WebDriver
[12:06:55] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[12:06:57] E/launcher - Error: Error: Cannot find module 'cucumber'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at Object.module.exports.load (/opt/protractor_tests/node_modules/protractor-cucumber-framework/lib/cucumberLoader.js:5:12)
at Object.<anonymous> (/opt/protractor_tests/node_modules/protractor-cucumber-framework/index.js:5:48)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
[12:06:57] E/launcher - Process exited with error code 100

Getting error "Failed: Fn is not a function" when try to automate e2e for a login page

I am trying to automate and rum a simple register form but i am getting error saying "Failed: Fn is not a function". Below is my code
describe('Locator testing by model', function(){
it('automate user register form', function(){
browser.get('http://www.way2automation.com/angularjs-protractor/registeration/#/login');
element(by.model('Auth.user.name')).sendKeys('angular');
element(by.model('Auth.user.password')).sendKeys('password');
element(by.model('model[options.key]')).sendKeys('zafaque');
element(by.buttonText('Login')).click();
browser.wait(3000);
});
});
below is the error detail
1) Locator testing by model automate user register form
Message:
Failed: fn is not a function
Stack:
TypeError: fn is not a function
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:716:14
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (node.js:369:9)
From: Task: <anonymous>
at pollCondition (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2359:16)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2355:9
at new ManagedPromise (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1082:7)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2354:14
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (node.js:369:9)
From: Task: <anonymous wait>
at ControlFlow.wait (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2352:17)
at Driver.wait (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:712:29)
at ProtractorBrowser.to.(anonymous function) [as wait] (/usr/local/lib/node_modules/protractor/built/browser.js:60:29)
at Object.<anonymous> (/Users/zafaque/WebstormProjects/autotation/udemyProject/loginTest.js:12:17)
at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:23
at new ManagedPromise (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1082:7)
at controlFlowExecute (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:80:18)
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25
From: Task: Run it("automate user register form") in control flow
at Object.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:79:14)
From asynchronous test:
Error
at Suite.<anonymous> (/Users/zafaque/WebstormProjects/autotation/udemyProject/loginTest.js:6:5)
at Object.<anonymous> (/Users/zafaque/WebstormProjects/autotation/udemyProject/loginTest.js:4:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
You are using browser.wait() incorrectly. Refer the official documentation for correct usage here
browser.wait() accepts params in the below order
first argument is a condition which can be a function or a
webdriver.promise.Promise or a Expected Condition Second Argument is
the timeout
But you are passing timeout as the first argument. Incase you just wait a conditionless wait - Just use browser.sleep(3000)

Meteor error - Storing tasks in a collection

I am following the meteor site tutorial (https://www.meteor.com/tutorials/blaze/collections).
But when you add the line:
export const Tasks = new Mongo.Collection('tasks');
I get the following error:
/Users/user/.meteor/packages/meteor-tool/.1.4.1_2.fpzmec++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313
throw(ex);
^
MongoError: failed to connect to server [localhost:27017] on first connect
at Object.Future.wait (/Users/user/.meteor/packages/meteor-tool/.1.4.1_2.fpzmec++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
at new MongoConnection (packages/mongo/mongo_driver.js:216:27)
at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)
at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
at new Mongo.Collection (packages/mongo/collection.js:103:40)
at meteorInstall.imports.api.tasks.js (imports/api/tasks.js:4:14)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
at Module.Mp.import (/Users/user/.meteor/packages/modules/.0.7.6_1.j54juu++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:70:16)
- - - - -
at [object Object].<anonymous> (/Users/user/.meteor/packages/npm-mongo/.1.5.50.1g0yl8n++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emitOne (events.js:77:13)
at [object Object].emit (events.js:169:7)
at [object Object].<anonymous> (/Users/user/.meteor/packages/npm-mongo/.1.5.50.1g0yl8n++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:260:12)
at [object Object].g (events.js:260:16)
at emitTwo (events.js:87:13)
at [object Object].emit (events.js:172:7)
at Socket.<anonymous> (/Users/user/.meteor/packages/npm-mongo/.1.5.50.1g0yl8n++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/connection.js:162:49)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
Exited with code: 1
Your application is crashing. Waiting for file change.
The line in the tutorial:
export const Tasks = new Mongo.Collection('tasks');
Is different from your line:
Export Tasks const = new Mongo.Collection ('tasks');
The goal of the code is to initialize a new constant, Tasks, set it to a new Mongo.Collection, and then export it.