why won't protractor recognize Angular ? - protractor

protractor is giving me errors telling me it can't find angular on the page. what else should I be considering to trouble shoot this ?
protractorConf.js
exports.config = {
seleniumAddress: 'http://0.0.0.0:4444/wd/hub',
capabilities: { 'browserName': 'chrome' },
specs: ['spec/javascripts/integration/main_spec.js'],
baseUrl: 'http://127.0.0.1:3000/',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
Failure message, a browser is actually opening, which is an improvement on where i was yesterday, any thoughts on this ?
jd#mbp ~/Dropbox/apps/lookingtolunch (master *)]$ protractor protractorConf.js
Using the selenium server at http://0.0.0.0:4444/wd/hub
F
Failures:
1) E2E: main page should find title element
Message:
Error: Angular could not be found on the page http://127.0.0.1:3000/ : angular never provided resumeBootstrap
Stacktrace:
Error: Angular could not be found on the page http://127.0.0.1:3000/ : angular never provided resumeBootstrap
at assertAngularOnPage (/usr/local/lib/node_modules/protractor/lib/protractor.js:668:13)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.executeScript()
at Protractor.get (/usr/local/lib/node_modules/protractor/lib/protractor.js:675:15)
at null.<anonymous> (/Users/jd/Dropbox/apps/lookingtolunch/spec/javascripts/integration/main_spec.js:16:13)
at /usr/local/lib/node_modules/protractor/jasminewd/index.js:54:12
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at null.<anonymous> (/usr/local/lib/node_modules/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

I am also getting the same problem, and since OP has gone silent, maybe I can use this answer space to give a second instance of the problem, and edit it to make it work based on other users feedback.
edit: I've found a solution. See edit at the bottom of the answer
I'm running Windows 8.1 running webdriver-manager start to launch Selenium standalone server, and python -m SimpleHTTPServer to host the site.
example-specs.js
describe("something peaceful", function() {
it("shouldn't be this hard", function() {
browser.get("http://127.0.0.1:8000"); // times out here
expect(true).toEqual(true);
});
});
conf.js
// protractor configuration for end-to-end (e2e) tests
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
capabilities: { 'browserName': 'chrome' },
specs: [ 'example-specs.js' ],
}
index.html
<!doctype html>
<html>
<body ng-app >
I can add: {{1+5}}.
<!-- script src="https://ajax.googleapis.com/ajax/libs/angularjs/**1.0.4**/angular.min.js"></script -->
<!-- Updated to 1.2.9 and the problem went away -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
</body>
</html>
edit 1
I was running from WebStorm, but I also tried serving the site using python -m SimpleHTTPServer (and changing the address accordingly), but my results are the same.
edit 2
If I remove baseUrl and call browser.get(...) directly, I can get http://www.angularjs.org work, but not my local site, nor this jsfiddle angular app I found. Maybe it's just not working for automatic bootstrapping?
edit 3
Significantly reduced code to reproduce (removed controller). Moved script to the end of the body as recommended.
edit 4
I was using an old version (1.0.4) of Angular that appeared in this book. Upgrading to 1.2.9 (latest) fixed the problem.

If you need to navigate to a page which does not use Angular then Add this line of code before browser.get() line there:
browser.waitForAngularEnabled(false);
Reference : https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load

Related

How to run Protractor specs on IE 11?

I have been trying to run protractor specs on IE 11,with following conf.js:
multiCapabilities: [
{
'browserName': 'internet explorer',
version: 11,
'ignoreProtectedModeSettings': true
// 'idle-duration':10000,
},
}],
And added this as well:
seleniumArgs: 'C:/Users/LJQAuser/AppData/Roaming/npm/node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer.exe',
And set directConnect to : false
But still its showing error:
Error in console is:
[12:38:42] I/local - Starting selenium standalone server...
[12:38:43] E/launcher - Error: Error: Server terminated early with status 1
at earlyTermination.catch.e (C:\Users\LJQAuser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:252:52)
at :null:null
at process._tickCallback (internal/process/next_tick.js:188:7)
Closing report
[12:38:43] E/launcher - Process exited with error code 100
There is tons of issues with internet explorer. Probably you wont be able to run it successfully.
There is alot of manual steps also to be applied.
Here is some basic guide how to setup:
Protractor test in IE
https://qavalidation.com/2017/11/run-protractor-test-ie-internet-explorer.html/
Good luck!

ECONNREFUSED Webdriver errors in eclipse when running Protractor

So, I was following this tutorial on getting my existing protractor files imported to Eclipse as Java project, installing angular/protractor configurations on eclipse and running the files:
https://www.youtube.com/watch?v=8dZ3isYcthI
But then I got into the weeds on this error: Error while running conf.js file from Eclipse
In attempt to resolve it, following instructions on the youtube tutorial, I replaced the selenium webdriver folder in Eclipse with the selenium webdriver folder in my node modules folder in AppData by dragging and dropping
Now my conf.js file will not run as protractor on Eclipse even though the file will execute successfully from the command line. Error is:
(node:53640) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[15:11:38] I/launcher - Running 1 instances of WebDriver
[15:11:38] I/hosted - Using the selenium server at http://localhost:4444 /wd/hub
[15:11:39] E/launcher - Error code: 135
[15:11:39] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
[15:11:39] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 at ClientRequest. (C:\Workspace\testUltimateQASite\node_modules\selenium-webdriver\http\index.js:238:15)
The js line it is pointing to in the index file is the last line of this function:
request.on('error', function(e) {
if (e.code === 'ECONNRESET') {
setTimeout(function() {
sendRequest(options, onOk, onError, opt_data, opt_proxy);
}, 15);
} else {
var message = e.message;
if (e.code) {
message = e.code + ' ' + message;
}
onError(new Error(message));
}
});
My conf.js file is as follows:
// conf.js
//var jasmineReporters = require('jasmine-reporters');
var os = require('os'); os.tmpDir = os.tmpdir;
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['qaSpec.js'],
//module.exports = {
params: {
url : 'http://phptravels.com/demo/'
/* login: {
url: 'http://phptravels.com/demo/',
username: 'juliel#ibm.com',
password: 'password'
}*/
}
};
The error is basically stating that your Selenium server doesn't seem to be running. Notice how you are seeing a connection refused error.
Please check if you have started the selenium server as described in the official documentation here : http://www.protractortest.org/#/tutorial#setup
For more information on setting up eclipse and protractor you might want to refer here as well :https://github.com/angelozerr/angularjs-eclipse/wiki/Protractor
I tried to understand your project's architecture by reading post several times and still got a bit confused.
I am not sure how do you manage Webdriver?
For Protractor project I would recommend using proper NodeJS project's structure as well as using any JS task runner. Grunt might be a good choice.
There are plenty Webdriver Manager plugins as well as Protractor managers so you will be able to load your project's dependencies and run test with single Grunt command.
UPDATE: this demo project might be useful in understanding the use of Grunt and its dependencies in Angular project's architecture.

App works locally but not on Heroku (Application Error); Using Nodemon and Webpack

Alright, I've tried to look up my question on StackOverflow but I can't find something that helps me since everything I've tried doesn't have any effect on the result (Application error).
So I'm really stumped because the app works perfectly fine on my localhost, but I can't get it to work on Heroku, it just gives me a Application error so I have no idea what the issue is.
So on my package.JSON file looks like this:
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --use_strict index.js",
"bundle": "webpack"
},
And I've already tried to change "nodemon" to "node" and gotten rid of --use_strict and ran it on local host and it still works perfectly fine but the Heroku app still gives me a Application Error.
index.js the only thing that I can think of being bad (changed it and it runs here):
// start the server
app.listen(3000, () => {
console.log('Server is running.');
});
webpack.config.js:
const path = require('path');
module.exports = {
// the entry file for the bundle
entry: path.join(__dirname, '/client/src/app.jsx'),
// the bundle file we will get in the result
output: {
path: path.join(__dirname, '/client/dist/js'),
filename: 'app.js',
},
module: {
// apply loaders to files that meet given conditions
loaders: [{
test: /\.jsx?$/,
include: path.join(__dirname, '/client/src'),
loader: 'babel-loader',
query: {
presets: ["react", "es2015"]
}
}],
},
// start Webpack in a watch mode, so Webpack will rebuild the bundle on changes
watch: true
};
It deployed properly after git push heroku master:
https://c1.staticflickr.com/3/2873/33519283263_3d9a711311_z.jpg
I'm pretty much trying to make this app work on Heroku:
https://vladimirponomarev.com/blog/authentication-in-react-apps-creating-components
I think a possible problem might be that you have to run "run bundle" on one shell and "npm start" in the other shell.
Another thing, this app had a lot of things that were npm installed manually in node_modules, which Heroku does not accept if I try to push it on github and will crash, so I'm thinking that might be an issue as well, though I have no idea how to get around that.
This also uses Express and Mongodb, and I added my mongodb info into the index.json file and ran the application, and it worked perfectly fine and after checking the db, the correct info was also inside it, so it's not that either.
You should use process.env.PORT instead of custom port 3000.
Check that you have a mongodb addon purchased, you can get one for free but for limited spacing!
And use the config vars of that database, if you haven't done that already!

BrowserStack + Protractor + TravisCi and secure localhost server - configuration

Trying to have an e2e test to test my server and it's UI on TraviCI. I'm however not able to come up with the necessary configuration in order to run all the components and access seleniumServer on BrowserStack.
I am able to get my session started, but when launching a browser to https://localhost:3000/login I see that the browser shows a page not found. If I manually run the ./BrowserStackLocal tool and use browserstack to access my localhost, I can do so no problem.
Here are my files:
./travis.yaml
....
addons:
browserstack:
username: "<my username>"
access_key:
secure: "<secure key goes here>"
config.js
var browserstack = require('browserstack-local');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'specs/*.js'
],
'seleniumAddress': 'http://hub.browserstack.com/wd/hub',
'capabilities': {
'browserstack.user': '<my username>', //<<--- I also had a version without these properties for browserstack, and that didn't work either
'browserstack.key': '<my key>',
'browserName': 'chrome',
'acceptSslCerts': true,
'browserstack.debug': true,
'chromeOptions': {
'excludeSwitches': ["disable-popup-blocking"]
}
},
baseUrl: 'https://localhost:3000/',
rootElement: 'div[ng-app]',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
// Code to start browserstack local before start of test
beforeLaunch: function(){
console.log("Connecting local");
return new Promise(function(resolve, reject){
exports.bs_local = new browserstack.Local();
exports.bs_local.start({'key': exports.config.capabilities['browserstack.key'] }, function(error) {
if (error) return reject(error);
console.log('Connected. Now testing...');
resolve();
});
});
},
// Code to stop browserstack local after end of test
afterLaunch: function(){
return new Promise(function(resolve, reject){
exports.bs_local.stop(resolve);
});
}
};
Since you are testing your local/private environment on BrowserStack Automate you have to follow these steps:
1) Create the Local Testing connection via the BrowserStackLocal Binary.
2) Add the capability 'browserstack.local' : true in your config file.
I do not see the capability in the config.js file. Add the capability and things should work.
Your script looks similar to the one here.
I ran into this same problem myself recently. First, Ashwin is right that you need to add 'browserstack.local' : true to your protractor config file. Next you need to add "browserstack-local": "^1.3.0" to package.json under devDependencies. This is required for the Browserstack Local binary to be installed on your build server.
package.json:
...
"devDependencies": {
"browserstack-local": "^1.3.0"
}
Beyond that, it is not a problem with the config/setup. Rather, it is how you kick off the tests that affects the port your app is served on.
The reason it works when you run with the local binary is because your app is started on http://localhost:3000.
But when you build and run the app via Travis (by running ng e2e or similar), it actually starts your app on a different port (refer to this post for more on the angular ports). You can confirm this by looking at the console log, it should start with something like this:
> ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
In the example above, it started on port 49152. So now if you have localhost:3000 hardcoded somewhere in your test spec, it won't find anything there. To fix this, in your test spec file, instead of browser.get('http://localhost:3000/login'), try browser.get(browser.baseUrl + '/login').
I realize this answer is probably too late for you, but hopefully it will be helpful to others.

Protractor test's within Webstorm has no Browser Connection

While trying to start the default protractor tests, WebStorm or protractor can not launch the default pages inside the Browser.
The Error Message is a simple Exception:
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
The setup for protractor is as follows:
The protractor.conf.js is as follows
exports.config = {
allScriptsTimeout: 11000,
specs: [
'*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:8000/app/',
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
and the tests are the default webstorm tests.
Configuration looks OK.
Please make sure you have started the local webserver on port 8000 (npm start) prior to running protractor - webserver needs to be serving up the application, so that Protractor can interact with it.
Also, make sure that web driver is installed (npm run update-webdriver)