e2e testin with jasmine protractor "no specs found" - angularjs

I'm new testing with protractor, but I cant run my tests.
My protractor.config.js:
exports.config = {
allScriptsTimeout: 99999,
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'chrome'
},
baseUrl: 'http://localhost:8080/',
framework: 'jasmine',
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['.src/test/e2e/login.e2e.spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose: true,
includeStackTrace: true
}
};
and this is the test I'm trying to run:
'use strict';
describe('my app', function() {
beforeEach(function () {
browser.get('index.html');
});
it('should automatically redirect to / when location hash is empty', function() {
expect(browser.getLocationAbsUrl()).toMatch("/");
});
});
And this is the error I get:
I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[13:20:49] I/launcher - Running 1 instances of WebDriver
Started
No specs found
Finished in 0.001 seconds
[13:20:50] I/launcher - 0 instance(s) of WebDriver still running
[13:20:50] I/launcher - chrome #01 passed
[13:20:50] The following tasks did not complete: e2e
[13:20:50] Did you forget to signal async completion?
I'm running webdriver-manager and my app server. My jasmine version is: 2.5.2
and my protractor version is:
4.0.9
Any idea of what I'm doing wrong??
Thanks!!!

I realized what was my problem (thanks to the comments that helped me to realize).
I was running my test with a gulp task I made:
function e2e() {
gulp.src(["/src/test/*.js"]).pipe(protractor({
configFile: "conf/protractor.config.js",
args: ['--baseUrl', 'http://localhost8080']
})).on('error', function (e) {
throw e;
});
}
I dont know why this: gulp.src(["/src/test/*.js"])wasnt getting to acces to my test files, so I changed it for: gulp.src(["src/test/e2e/login.e2e.spec.js"])
I know its not the best solution,but enough to survive...

Related

AngularJs Protractor Html Reporter Fails Config Parser

I am trying to use protractor html screenshot reporter but it's failing to require in the the config file. Here's my config:
//Configuration for Protractor
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter = new HtmlReporter({
baseDirectory: '/screenshots',
takeScreeenShotOnlyForFailedSpecs: true
});
exports.config = {
//Address of Selenium server
seleniumAddress: 'http://localhost:4444/wd/hub',
//framework: 'jasmine2',
chromeOnly: false,
multiCapabilities: [
{'browserName': 'chrome'}
],
//URL of the application
baseUrl: 'http://localhost:80',
cache: false,
//Spec pattern
specs: ['**/specs/*-spec.js'],
onPrepare: function () {
//browser.driver.manage().window().maximize();
browser.driver.manage().window().setSize(480, 800);
browser.driver.manage().window().setPosition(400, 100);
jasmine.getEnv().addReporter(reporter);
},
//Options passed to Jasmine-node
jasmineNodeOpts: {
includeStackTrace: true,
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose: true,
}
};
I have both protractor and the protractor html screenshot report installed globally . Here's the error protractor is throwing:
[13:48:23] E/configParser - error code: 105
[13:48:23] E/configParser - description: failed loading configuration file protractor-config.js
Any help would be most helpful!!
UPDATE:
I moved to the require call inside the onPrepare in the config and I getting the proper error:
[14:27:15] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[14:27:15] I/launcher - Running 1 instances of WebDriver
[14:27:18] E/launcher - Error: Error: Cannot find module 'protractor-html-screenshot-reporter'
Seems like it can't find the node module. Anyone else seeing this issue?
UPDATE2:
So, I think I found my problem. I was installing like this:
npm install -g protractor-html-screenshot-reporter
Which seems to be the cause the fail. Installing with this command:
npm install protractor-html-screenshot-reporter --save-dev
Works! For whatever reason installing globally doesn't work but installing locally does, which is a bit of a downer :( If anyone knows how to get this to work with the screenshot reporter installed globally let me know how :)

Why I get this error in Protractor of Jasmine timeout and how can i test correctly?

I posted an issue because I thought it was a bug with something to do with Jasmine.
Here is link: https://github.com/angular/protractor/issues/3130#event-628418439
I try to run a simple request to the server. The server reply and angular shows the message but the test freezes and i get the error below.
I am new in e2e (testing in general). Am I doing something wrong or it is a bug.
protractor protractor-e2e.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.115:54697/wd/hub
Started
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
F
Failures:
1) Registration view should ask for a proper email "The email must be a valid email address."
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
Ran 1 of 9 specs
1 spec, 1 failure
Finished in 27.718 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #01 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
```
protractor --version
Version 3.2.2
==UPDATE : complete test ==
'use strict';
var fulanito = {
name: 'Fulano',
last_name: 'De Tal',
email: 'fulanitodetal2#fulandolandia.com.mx',
password: 'lacontraseñadefulanito',
};
describe('Registration view', function() {
beforeEach(function() {
browser.get('#/account/register');
browser.manage().logs().get('browser').then(function(browserLog) {
console.log('log: ' + require('util').inspect(browserLog));
});
});
fit('should aske for a proper email "The email must be a valid email address."', function function_name(argument) {
var inputname = element(by.model('userData.name')).sendKeys(fulanito.name);
var inputname = element(by.model('userData.last_name')).sendKeys(fulanito.last_name);
var inputemail = element(by.model('userData.email')).sendKeys('fulanito#ara');
var inputpassword = element(by.model('userData.password')).sendKeys(fulanito.password);
var inputpassword_confirmation = element(by.model('userData.password_confirmation')).sendKeys(fulanito.password);
});
it('should see "Registro"', function() {
expect(element(by.css('h1')).getText()).toContain('Registro');
});
My config file
exports.config = {
allScriptsTimeout: 99999,
// The address of a running selenium server.
//seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
onPrepare: function() {
// you can also add properties to globals here
global.host= 'http://localhost:9000/';
},
keepAlive: true, //intesive testing
baseUrl: 'http://localhost:9000',
//Stand alone: 9001
//baseUrl: 'http://localhost:9001',
framework: 'jasmine',
// Spec patterns are relative to the current working directly when
// protractor is called.
//specs: ['test/e2e/*.js'],
specs: ['test/e2e/register-spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 25000,
isVerbose: true,
includeStackTrace: true
}
};
It turns out that there is an error in my code and possible a bug.
fit('should aske for a proper email "The email must be a valid email address."', function function_name(argument) {
var inputname = element(by.model('userData.name')).sendKeys(fulanito.name);
var inputname = element(by.model('userData.last_name')).sendKeys(fulanito.last_name);
var inputemail = element(by.model('userData.email')).sendKeys('fulanito#ara');
var inputpassword = element(by.model('userData.password')).sendKeys(fulanito.password);
var inputpassword_confirmation = element(by.model('userData.password_confirmation')).sendKeys(fulanito.password);
});
The stupid error is that I used the autocomplete for function: function function_name(argument) {} and that causes the error. So one must put : function () {} without the argument. : |
Just to clarify, this argument is designed to be a done function/callback. If you specify it, you have to call it manually when the test is finished. If you don't call it, the test would freeze until a jasmine global timeout is reached. This is exactly what is happening in this case.

Timeout error after adding untrackOutstandingTimeouts:true in protractor conf

My protractor conf looks like this:
exports.config = {
seleniumServerJar: "../node_modules/protractor/selenium/selenium-server-standalone-2.51.0.jar",
seleniumPort: 4444,
baseUrl: baseUrl,
specs: specs,
untrackOutstandingTimeouts:true,
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 3600000
},
framework: "jasmine2"
}
I am trying perform action on angular page but fails with error -
Failed: Timed out waiting for Protractor to synchronize with the page after 150 seconds.
Please see https://github.com/angular/protractor/blob/master/docs/faq.md.
The following tasks were pending:
- $http: /api/v1/query/tail/242ac110002-8/1h?t=1456925874600
I have added untrackOutstandingTimeouts:true in protractor conf, still I am getting above error.
Protractor Version - 3.1.1
Node version - 4.3.1
Selenium-webdriver - 2.51.0
Thanks in advance!
Able to solve above problem using browser.ignoreSynchronization
browser.get('/');
browser.ignoreSynchronization=true;
//Go to page where $http and $timeout is added
//Perform any action, steps here
browser.sleep(5000); //This can be replace with wait condition
browser.ignoresynchronization=false

Error while waiting for Protractor to sync with the page: in Protractor IE11 execution

I am getting error in IE11 as
Error while waiting for Protractor to sync with the page: "root element (body) has no injector. this may mean it is not inside ng-app.
when I execute my protractor scripts.I set framework: jasmine2 but it didn't help out.However same working fine in Chrome and Firefox.
Following is my code:
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
//config.seleniumAddress = 'http://127.0.0.1:4444/wd/hub';
maxSessions: 1,
capabilities:
{
'browserName': 'internet explorer'
},
framework: 'jasmine',
specs: ['TC_Sprint2_Case1.js'],
onPrepare: function() {
beforeEach(function() {
browser.driver.manage().window().setSize(1280, 1024);
});
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'D:/Manoj/TestReport3/',
docTitle: 'Test Case Execution Details',
docName: 'BYTestReport.html',
//Meta builder
metaDataBuilder: function(spec, descriptions, results, capabilities){
var metaData = {
description: descriptions.join('|'),
passed: results.passed(),
os: 'Windows 7',
browser: {
name: capabilities.caps_.browserName
, version: capabilities.caps_.version
}
};
if(results.items_.length > 0) {
var result = results.items_[0];
metaData.message = result.message;
metaData.trace = result.trace.stack;
}
return metaData;
} // Meta Builder ends
}));
},
We can use browser.driver.get('https://google.co.in'); instead of browser.get('https://google.co.in');
Earlier I used browser.get(URL). It caused the synchronization problem.When I use browser.driver.get(URL).It solved the problem.
In your config, try setting nativeEvents to false:
capabilities:{
browserName: 'internet explorer'
nativeEvents:false
},
IE sometimes hangs on startup and this seems to solve it for me. This being said, there are other things that could cause IE to not bind.

protractor "ERROR - Unable to start a WebDriver session"

I have some it tests on my single-page-app written in angular.
the tests are in protractor.
they ran during the build before, but now that I moved all of them to a branch something got broken and when I run the tests I'm getting:
Running "protractor:normal" (protractor) task
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://172.31.9.226:23730/wd/hub
ERROR - Unable to start a WebDriver session.
c:\projects\blog-manager\node_modules\protractor\node_modules\selenium- webdriver\lib\atoms\error.js:113
var template = new Error(this.message);
^
Warning: Protractor test(s) failed. Exit code: 1 Use --force to continue.
Aborted due to warnings.
Process finished with exit code 6
the conf file is as follows:
'use strict';
module.exports.config = {
allScriptsTimeout: 60000,
baseUrl: 'http://localhost:9000/',
specs: [
process.cwd() + '/test/spec/e2e/**/*.js'//,
// process.cwd() + '/test/e2e/spec/**/*.js'
],
framework: 'jasmine',
capabilities: {
browserName: 'chrome',
"chromeOptions": {
binary: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
args: [],
extensions: [],
}
},
onPrepare: function () {
// Disable animations so e2e tests run more quickly
var disableNgAnimate = function () {
angular.module('disableNgAnimate', []).run(function ($animate) {
$animate.enabled(false);
});
};
browser.addMockModule('disableNgAnimate', disableNgAnimate);
// Store the name of the browser that's currently being used.
browser.getCapabilities().then(function (caps) {
browser.params.browser = caps.get('browserName');
});
},
jasmineNodeOpts: {
defaultTimeoutInterval: 300000
}
};
any suggestions on how to solve this would be much appreciated.
Thanks!
According to alecxe's answer it's chrome binary issue which can be solved by installing chrome in same place as chromedriver expects to be or specifying the executable path to the binary settings.
capabilities: {
"browserName": "chrome",
"chromeOptions": {
binary: "D:/Program Files/Chrome/chrome.exe",
args: [],
extensions: [],
}
},
See his answer here
Even though you are setting the executable path correctly it seems little off to me binary: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
Is this correct?
Alternatively, I would try this

Resources