I have been through various posts but unable to find a solution.
HTML:
<div class="col-xs-3" ng-repeat="post in posts track by $index">
<div class="well">
<h3 class="postTitle">
<a ui-sref="singlePost({id:post.id,permalink:post.permalink})">
{{post.title}}
</a>
</h3>
<h5>By: {{post.author}} | {{post.datePublished}}</h5>
</div>
</div>
scenario.js:
'use strict';
/* https://github.com/angular/protractor/blob/master/docs/toc.md */
describe('The Single Page Blogger E2E Test', function() {
var ptor = browser; // browser === protractor.getInstance();
// ptor.get('/'); //go to http://localhost:8000
beforeEach(function() {
ptor.get('app');
});
it('Should have 4 posts', function() {
var posts = element.all(by.repeater('post in posts'));
expect(posts.count()).toBe(4); // we have 4 hard coded posts
});
it('Should redirect to #/posts/1/sample-title1', function() {
var posts = element.all(by.repeater('post in posts'));
posts.first().then(function(postElem) {
postElem.findElement(by.tagName('a')).then(function(a) {
a.click(); //click the title link of 1st post
expect(ptor.getCurrentUrl()).toMatch('/posts/1/simple-title1');
});
});
});
});
protractor.conf.js:
exports.config = {
allScriptsTimeout: 11000,
specs: [
'specs/*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:8000',
framework: 'jasmine2',
jasmineNodeOpts: {
onComplete: null,
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};
This is the log from the terminal:
angular-seed#0.0.0 preprotractor /var/www/angularjs-seed
npm run update-webdriver
angular-seed#0.0.0 preupdate-webdriver /var/www/angularjs-seed
npm install
angular-seed#0.0.0 postinstall /var/www/angularjs-seed
bower install
angular-seed#0.0.0 update-webdriver /var/www/angularjs-seed
webdriver-manager update
selenium standalone is up to date.
chromedriver is up to date.
angular-seed#0.0.0 protractor /var/www/angularjs-seed
protractor test/e2e-tests/protractor.conf.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.1.185:38493/wd/hub
Started
.F
Failures:
1) The Single Page Blogger E2E Test Should redirect to #/posts/1/sample-title1
Message:
Failed: undefined is not a function
Stack:
TypeError: undefined is not a function
at Object.<anonymous> (/var/www/angularjs-seed/test/e2e-tests/specs/scenarios.js:21:19)
at runMicrotasksCallback (node.js:337:7)
at process._tickCallback (node.js:355:11)
From: Task: Run it("Should redirect to #/posts/1/sample-title1") in control flow
at attemptAsync (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1819:24)
at QueueRunner.run (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1774:9)
at /var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
at /var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
at Array.forEach (native)
From asynchronous test:
Error
at Suite.<anonymous> (/var/www/angularjs-seed/test/e2e-tests/specs/scenarios.js:18:3)
at addSpecsToSuite (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:743:25)
at Env.describe (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:713:7)
at jasmineInterface.describe (/var/www/angularjs-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:3219:18)
at Object.<anonymous> (/var/www/angularjs-seed/test/e2e-tests/specs/scenarios.js:5:1)
2 specs, 1 failure
Finished in 1.679 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
npm ERR! Linux 3.13.0-62-generic
npm ERR! argv "node" "/usr/local/bin/npm" "run" "protractor"
npm ERR! node v0.12.7
npm ERR! npm v2.13.4
npm ERR! code ELIFECYCLE
npm ERR! angular-seed#0.0.0 protractor: `protractor test/e2e-tests/protractor.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-seed#0.0.0 protractor script 'protractor test/e2e-tests/protractor.conf.js'.
npm ERR! This is most likely a problem with the angular-seed package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor test/e2e-tests/protractor.conf.js
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-seed
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/angularjs-seed/npm-debug.log
Line 22:19 points to then in posts.first().then(function(postElem) {});.
I am not understanding what's the mistake in the code as I have checked in one of the stack overflow posts and also through the protractor api guide that we can chain first().then <-- like this. Can anyone please help me with this?
There was a breaking change. There is no element.then() since 2.0.0.
Use instead:
posts.first().element(by.tagName('a')).click();
expect(browser.getCurrentUrl()).toMatch('/posts/1/simple-title1');
Related
I have created a Simple React App and succeed because it already showed the happy hacking message on cmd, however when i type and ran "npm start" on cmd it gives a lot of errors. I've tried to uninstall then install the node and npm several times but it still doesn't work. here's the error message
Creating a new React app in C:\myapp2.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
> core-js#2.6.10 postinstall C:\myapp2\node_modules\babel-runtime\node_modules\core-js
> node postinstall || echo "ignore"
> core-js#3.2.1 postinstall C:\myapp2\node_modules\core-js
> node scripts/postinstall || echo "ignore"
+ react-dom#16.11.0
+ react#16.11.0
+ react-scripts#3.2.0
added 1475 packages from 693 contributors and audited 904933 packages in 828.526s
found 0 vulnerabilities
Success! Created myapp2 at C:\myapp2
Starting the development server...
events.js:187
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:3000/' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp2#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp2#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ASUS\AppData\Roaming\npm-cache\_logs\2019-11-13T21_57_29_371Z-debug.log
I hope you guys can help me to point out where i should make changes so it can work successfully. thanks in advance !
after creating a project with create-react-app
create-react-app name
you have to go inside the created folder
cd name
and then run
npm start
again
first create a folder in one Drive( D: or E:),open it in command prompt and create a react app like:
npm create-react-app project name
or
npx-create-react-app project name
cd project name
npm start
I am creating my 1st protractor framework and I am trying run a sample test locally within my project. I can update and start webdriver fine. No issues at all. Super confused where I went wrong!
I got to project level and performed the command
npm run protractor
I got the following message from my mac terminal
Jacquelines-MacBook-Air:JSworkspace jacquelinegeorge$ cd LocatorTraining
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$ npm run protractor
> LocatorTraining# protractor /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining
> protractor configurations.js
[11:12:24] I/launcher - Running 1 instances of WebDriver
[11:12:24] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
F
Failures:
1) protractor page Object training encountered a declaration exception
Message:
ReferenceError: datadrive is not defined
Stack:
ReferenceError: datadrive is not defined
at Object.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/data.js:10:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Suite.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:3:9)
Message:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
Stack:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.manage().window().maximize()
at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:10:37)
at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
1 spec, 1 failure
Finished in 0.136 seconds
[11:12:27] I/launcher - 0 instance(s) of WebDriver still running
[11:12:27] I/launcher - chrome #01 failed 1 test(s)
[11:12:27] I/launcher - overall: 1 failed spec(s)
[11:12:27] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining# protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining# protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
So I checked the configurations.js file which looks like (that's the correct Spec.js file that I am testing):
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['PageObjectLocator1.js'],
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
browser.driver.manage().window().maximize();
//logs
//command for non angular web site
//reporting
//site Url???
}
}
Then I went to the run configurations and cli.js in the project
so I checked my Spec file I had no errors.
describe('protractor page Object training',function(){
var obj= require("./PageObjectDemo.js");
var d= require("./data.js");
beforeEach(function() {
obj.geturl();//the url on your test page is a method
});
it('Perform Simple Calculation ',function(){
// write your code here!!!
obj.firstnumber.sendKeys(d.datadrive.firstinput);//page of object properties
obj.secondnumber.sendKeys(d.datadrive.secondinput);//page object properties
obj.gobutton.click();
//Jasmine Attribute Syntax toBe. Jasmine takes care of the promise 'resolve'internally
expect(obj.result.getText()).toBe(d.datadrive.result);
//this confirm printout in console.
obj.result.getText().then(function(text){
console.log(text)
}) //end of console log message
})//end of it block
afterEach(function () {
console.log("If you can see this, test is completed. Well Done!!");
});
So I checked the data spec file :
module.exports.datadrive=
{
firstinput:"3",
secondinput:"5",
result: "8"
}
console.log(datadrive.result);
Following Yong suggestion, I updated to:
exports.datadrive = {
firstinput:"3",
secondinput:"5",
result: "8"
}
Got the following result:
[17:16:06] I/launcher - 0 instance(s) of WebDriver still running
[17:16:06] I/launcher - chrome #01 failed 1 test(s)
[17:16:06] I/launcher - overall: 1 failed spec(s)
[17:16:06] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining# protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining# protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
OK, on saturday I updated my node.js ( installed updated node.js globally, however I run my npm run protractor a local project level. Did do something wrong doing that?) and ran the Spec file again. Got the following message (sigh). I really don't know what I did wrong. I'm utterly confused.
Failures:
1) protractor page Object training Perform Simple Calculation
Message:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
Stack:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.manage().window().maximize()
at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:10:37)
at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
Message:
Failed: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
Stack:
Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/browser.js:463:23)
at ManagedPromise.invokeCallback_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:103:7)Error
at ElementArrayFinder.applyAction_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:459:27)
at ElementArrayFinder.(anonymous function) [as sendKeys] (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:91:29)
at ElementFinder.(anonymous function) [as sendKeys] (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:831:22)
at UserContext.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:14:19)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:112:25
at new ManagedPromise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:1077:7)
at ControlFlow.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:2505:12)
at schedulerExecute (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:95:18)
at TaskQueue.execute_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3067:27)
From: Task: Run it("Perform Simple Calculation ") in control flow
at UserContext.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:94:19)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
From asynchronous test:
Error
at Suite.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:11:2)
at Object.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator1.js:1:63)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
1 spec, 1 failure
Finished in 0.186 seconds
[12:40:08] I/launcher - 0 instance(s) of WebDriver still running
[12:40:08] I/launcher - chrome #01 failed 1 test(s)
[12:40:08] I/launcher - overall: 1 failed spec(s)
[12:40:08] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining# protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining# protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$
The wrong comes from your data.js , try change as following:
exports.datadrive = {
firstinput:"3",
secondinput:"5",
result: "8"
}
Ok, I found the root cause of my problem. I noticed the error messages they kept mentioning "protractor": + my config.js file.
So I decided to reconfigure this part of my package.json file.
note: I had already updated my node.js on my machine using this method
I went into the .bin folder (I'm a mac user so pressed shift+cmd+. to reveal this hidden folder) and dragged n dropped the location of the protractor command file into my package.json file.
then I linked it to the configurations.js file ensuring the spelling was correct.
Pressed shift+cmd+.again to hide the .bin folder
Saved the updated package.json file
opened a terminal and went to project at local level using cd and ls commands
ran npm run start to start protractor servers
ran npm run protractor to run test
TEST RAN PERFECTLY!!!!!
running tests on protractor I keep getting a message that there is something wrong with my config file (which worked perfectly 2 days ago).
I would appreciate some help fixing this.
What did I do wrong?
How do I fix this?
Things to consider:
npm was updated globally 2 days ago (to version 11)
The package.json file was was set up correctly. Was able to run a
test with no problems on saturday.
looking through the logs I think this is the issue:
npm ERR! LocatorTraining# protractor: `protractor configurations.js`
Looking through my configurations.js file, I've only added Html reporter to it. Nothing else.
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['PageObjectLocator1.js'],
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
browser.driver.manage().window().maximize();
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
}
This is the message from the terminal
[16:27:25] I/launcher - 0 instance(s) of WebDriver still running
[16:27:25] I/launcher - chrome #01 failed 1 test(s)
[16:27:25] I/launcher - overall: 1 failed spec(s)
[16:27:25] E/launcher - Process exited with error code 1
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining# protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining# protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
This is the package.json file which was working 2 days ago.
{
"name": "LocatorTraining",
"dependencies": {
"protractor": "^5.4.1",
"jasmine-data-provider": "^2.2.0",
"protractor-jasmine2-html-reporter":"^0.0.7"
},
"scripts": {
"webdriver-update": "./node_modules/.bin/webdriver-manager update",
"webdriver-start": "./node_modules/.bin/webdriver-manager start",
"protractor": "./node_modules/.bin/protractor configurations.js",
"start": "npm run webdriver-update && npm run webdriver-start"
}
}
I seem to have an issue with running my tests in Google Chrome at the moment. When I ran this test in FF it worked fine. So the code is fine. So what I will do is find out why chrome is NOT allowing me to run my tests.
I got the following error when running a sample regression test:
TypeError: config.suite.split is not a function
Here is the the configuration file. It looks ok but I must have missed something but I can't honestly find what it could be.
Configuration.js file (this was working few days ago)
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['PageObjectLocator2.js'],
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
browser.driver.manage().window().maximize();
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
},// end of onPrepare
suite:
{
Smoke : ['ChainLocator.js','dropDowns.js'],
Regression : 'nonAnuglarSpec.js'
},
//Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
}
This is the package.json file. Could the issues here but honestly don't know
{
"name": "LocatorTraining",
"dependencies": {
"protractor": "^5.4.1",
"jasmine-data-provider": "^2.2.0",
"protractor-jasmine2-html-reporter":"^0.0.7"
},
"scripts": {
"webdriver-update": "./node_modules/.bin/webdriver-manager update",
"webdriver-start": "./node_modules/.bin/webdriver-manager start",
"protractor": "./node_modules/.bin/protractor configurations.js",
"SmokeTest": "./node_modules/.bin/protractor configurations.js --suite Smoke",
"RegressionTest": "./node_modules/.bin/protractor configurations.js --suite Regression",
"start": "npm run webdriver-update && npm run webdriver-start"
}
}
Message from termaminal.
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$ npm run RegressionTest
> LocatorTraining# RegressionTest /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining
> protractor configurations.js --suite Regression
/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:155
throw e;
^
TypeError: config.suite.split is not a function
at Function.getSpecs (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/configParser.js:86:26)
at new TaskScheduler (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/taskScheduler.js:34:100)
at helper.runFilenameOrFn_.then.then.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/launcher.js:175:25)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:604:44
at runSingle (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:137:13)
at flush (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:125:13)
at internalTickCallback (internal/process/next_tick.js:70:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! LocatorTraining# RegressionTest: `protractor configurations.js --suite Regression`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining# RegressionTest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jacquelinegeorge/.npm/_logs/2018-11-07T14_32_24_804Z-debug.log
modifying suite to 'suites' did fix part of the problem. However got the following error message:
[21:38:02] I/launcher - Running 1 instances of WebDriver
[21:38:02] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
F
Failures:
1) Opening non Angular website Opening google page
Message:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
Stack:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
From: Task: WebDriver.manage().window().maximize()
at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:11:37)
at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
1 spec, 1 failure
Finished in 0.143 seconds
[21:38:06] I/launcher - 0 instance(s) of WebDriver still running
[21:38:06] I/launcher - chrome #01 failed 1 test(s)
[21:38:06] I/launcher - overall: 1 failed spec(s)
[21:38:06] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! LocatorTraining# RegressionTest: `protractor configurations.js --suite Regression`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining# RegressionTest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jacquelinegeorge/.npm/_logs/2018-11-07T21_38_06_831Z-debug.log
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$
Just as https://www.protractortest.org/#/page-objects suggests your config's suites must be plural, not suite
However in cmd line, you should use --suite (not --suites) to give the suite name you defined in suites block in your config file.
suite:
{
Smoke : ['ChainLocator.js','dropDowns.js'],
Regression : 'nonAnuglarSpec.js'
},
suite is an plaint object, and those don't have a split method. This would imply that you've specified an invalid/unexpected type for suite.
Currently I have Protractor v.5.1.1, Node.js v.6.10.0
All protractor tests work in window console but when I try to run them from STS IDE I get below error. Of course i did 'webdriver-manager update' but it doesn't help at all. Does anyone has an idea how to resolve this problem?
Below the error respectively when I use or do not 'directConnect'
[22:21:48] I/launcher - Running 1 instances of WebDriver
[22:21:48] I/direct - Using ChromeDriver directly...
[22:21:48] E/direct - Error code: 135
[22:21:48] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[22:21:48] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
at IError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:5:1)
at ProtractorError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:10:9)
at BrowserError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:51:9)
at Direct.getNewDriver (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\direct.js:62:31)
at Runner.createBrowser (D:\STS_workspace\jgh\node_modules\protractor\built\runner.js:194:43)
at q.then.then (D:\STS_workspace\jgh\node_modules\protractor\built\runner.js:338:29)
at _fulfilled (D:\STS_workspace\jgh\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\STS_workspace\jgh\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\STS_workspace\jgh\node_modules\q\q.js:796:13)
at D:\STS_workspace\jgh\node_modules\q\q.js:556:49
[22:21:48] E/launcher - Process exited with error code 135
or
[21:19:23] I/launcher - Running 1 instances of WebDriver
[21:19:23] E/local - Error code: 135
[21:19:23] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[21:19:23] E/local - Error: No update-config.json found. Run 'webdriver- manager update' to download binaries.
at IError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:5:1)
at ProtractorError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:10:9)
at BrowserError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:51:9)
at Local.addDefaultBinaryLocs_ (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\local.js:40:23)
at Local.setupDriverEnv (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\local.js:81:14)
at Local.setupEnv (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\driverProvider.js:110:34)
at q.then (D:\STS_workspace\jgh\node_modules\protractor\built\runner.js:334:41)
at _fulfilled (D:\STS_workspace\jgh\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\STS_workspace\jgh\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\STS_workspace\jgh\node_modules\q\q.js:796:13)
[21:19:23] E/launcher - Process exited with error code 135
My conf.js looks like:
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
// directConnect:true,
specs: ['spec4.js'],
framework: 'jasmine2' ,
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true,
displaySuccessesSummary: true,
displayFailuresSummary: true,
displayPendingSummary: true,
displaySpecDuration: true,
},
}));
},
jasmineNodeOpts: {
defaultTimeoutInterval: 25000,
print: function () {},
},
I don't have selenium folder in the path node_modules/protractor/node_modules/webdriver-manager but I have package.json where I added "webdriver-update": "webdriver-manager update".
This is the output of npm run webdriver-update:
D:\STS_workspace\jgh>npm run webdriver-update
npm WARN invalid config proxy="http:"
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config proxy="http:"
npm WARN invalid config Must be a full url with 'http://'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "webdriver-update"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! path D:\STS_workspace\jgh\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'D:\STS_workspace\jgh\package.json'
npm ERR! enoent ENOENT: no such file or directory, open 'D:\STS_workspace\jgh\package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! D:\STS_workspace\jgh\npm-debug.log
It looks like you are either using directConnect or launching with a local driver provider (not having seleniumAddress or directConnect) in your configuration file. You need to run webdriver-manager update.
Previously I had extra flags to not download standalone or gecko with webdriver-manager update --standalone false --gecko false. This is no longer the case if you are starting via a local driver provider. You will need the selenium standalone jar file.
You could run this with a script in package.json. Something like:
"scripts": {
"webdriver-update": "webdriver-manager update"
}
Then execute this with: npm run webdriver-update. How do you check if the binaries are there? In your project, navigate to node_modules/protractor/node_modules/webdriver-manager/selenium/. This is where the update-config.json and your downloaded binaries are located.
You can try to update it like this, it will definitely update it in node_modules/protractor :
$ ./node_modules/protractor/bin/webdriver-manager update
Just execute webdriver-manager with npx command in your project folder;
npx webdriver-manager update
On MacOS, I resolved this error by adding the seleniumAddress to my Protractor config file (I was previously using directConnect, so commented that out):
// directConnect: true,
// baseUrl: 'http://localhost:4000/',
seleniumAddress: 'http://localhost:4444/wd/hub/',
I now start Protractor server by running: $ webdriver-manager start
And in a different terminal window, I start tests with: $ ng e2e
You just need to run this command and it fixes it - npm run webdriver-update it updates you webdriver in node_modules section under node_modules/protractor.
These 2 lines are the main culprits. Just try running that command and it should fix your issue.
[22:21:48] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[22:21:48] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
Hope that helps!
I ran npx webdriver-manager update command directly inside
$\node_modules\protractor\bin and it started working as expected.
traverse to the above mentioned folder inside your e2e and run command.
When I installed Java and updated Java Path in Windows 10, the problem was resolved.
In my case
npm run webdriver-manager update
updates only app\node_modules\webdriver-manager and not app\node_modules\protractor\node_modules\webdriver-manager\. No matter if I run that command directly from console or as package.json script.
I had to run
npx webdriver-manager update
inside app\node_modules\protractor\node_modules\webdriver-manager\.
Another solution would be this script:
"postinstall": "node ./node_modules/protractor/node_modules/webdriver-manager update"
With this I am able to proceed further
node node_modules/protractor/bin/webdriver-manager update