angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Complete Test fail, if any of data using data-provider is wrong for test, it will not execute test with next correct data in pipeline #2961

Closed Saurabh06 closed 8 years ago

Saurabh06 commented 8 years ago

I am running same test with different data using data-provider in protractor, if any one data for that particular test fails then it will not repeat the test with next data. It fails the complete test without checking for next data in pipeline. but i don't want to fail the test without checking for next data in pipeline only to fail that with wrong data.

NickTomlin commented 8 years ago

Hi there!

Your question is better suited for StackOverflow or Gitter. Please ask a question there with the 'protractor' tag or post in the Gitter Channel to get help.

From the the getting help section of the README:

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

Thanks!

Saurabh06 commented 8 years ago

Hi @sallojusuresh , Can you please look into this issue. Thanks in Advance

sallojusuresh commented 8 years ago

@Saurabh06

It's good to open new ticket in StackOverflow as they requested many times and please mention clear steps. Im not clear about your question.

Saurabh06 commented 8 years ago

Sorry @sallojusuresh and @NickTomlin, but no one is answering question on stack-overflow. That's why asked here. I am passing data Json file [ { "TestName" : "ABC", "someId": "123", "sendSomeKeys": "abc" }, { "TestName" : "ABC", "someId": "456", "sendSomeKeys": "abc1" } ]

Using Jasmine data-provider:

function using(values, func){ var jsonArr = []; var jsonDataValue =[]; var testData = require('./path/to/json.json'); testData.forEach( function (data) { if(data.TestName===values){ jsonArr.push(data); }}); jsonArr.forEach( function (data) { jsonDataValue.push(data); func.apply(this, jsonDataValue); }); }

And used in spec test -

using('ABC',function (data) { it('should read from an external json', function(){ element(by.id(data.someId)).sendKeys(data.sendSomeKeys); }); });

when the test runs for the first json data object i.e for someid = "123" and if the test get fail for the 1st json object data due to presence of wrong data then test will not run again for the someid= "456" even though data object is correct for second. can you please check once. As per data-provider concept test will fail for that data only in which wrong data is present but it will run and pass for another data, if data is correct as per testng data-provider concept

sallojusuresh commented 8 years ago

@Saurabh06 Can you put the Error log here? and all test cases are working fine in-case first test case passed right?

sallojusuresh commented 8 years ago

@Saurabh06 , I have tried with below code and its working perfectly. may be something wrong with your way of test logic handling Saurabh.

describe("Login Test", function () { 'use strict'; beforeEach(function () { browser.get(browser.baseUrl); }); function setOfLogins() { return [ {element_id: 'user1', uname: 'test@gmail.com'},/_in this elementid is wrong one/ {element_id: 'user', uname: 'test@gmail.com'}, {element_id: 'user', uname: 'test@gmail.com'} ] } using(setOfLogins, function (credentials) { it('test login', function () { element(by.id(credentials.element_id)).sendKeys(credentials.uname); }); }); });

You can see attached screenshot. perfectingworking_consoleoutput

Saurabh06 commented 8 years ago

yes @sallojusuresh, without using jasmine data-provider it is working fine but when i am using with data-provider function using(values, func){ var jsonArr = []; var jsonDataValue =[]; var testData = require('./path/to/json.json'); testData.forEach( function (data) { if(data.TestName===values){ jsonArr.push(data); }}); jsonArr.forEach( function (data) { jsonDataValue.push(data); func.apply(this, jsonDataValue); }); } if it fails on first scenario then it will not take others data and show the result as complete fail. Now it start giving new error can you check once. capture13

Saurabh06 commented 8 years ago

@sallojusuresh Can you please help me out why i am start getting this error, previously it is running fine but now when i am going to start protractor by running conf.js, it opens up browser and do nothing on browser and giving error on console.

sallojusuresh commented 8 years ago

@Saurabh06 Can uninstal protractor and install again and see

Saurabh06 commented 8 years ago

@sallojusuresh thanks for reply..

But still it is not working giving same error.. capture15

sallojusuresh commented 8 years ago

Issue seems to be jasmine-html-report report @Saurabh06 , can comment the code related to html-report on conf.js file and run it and also check that selenium server running port id is correct or not

Saurabh06 commented 8 years ago

Yes @sallojusuresh, It is working fine, if i remove logic written for reports using protractor-jasmine2-html reporter:

/onPrepare: function() { var capsPromise = browser.getCapabilities(); capsPromise.then(function(caps){ var browserName = caps.caps.browserName.toUpperCase(); var browserVersion = caps.caps.version; var platform = caps.caps.platform; var prePendStr = browserName + "" + browserVersion + ""+ platform+ "_"; browser.manage().timeouts().pageLoadTimeout(40000), browser.manage().timeouts().implicitlyWait(30000), jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({ consolidateAll: true, savePath: __dirname+'/../TestOutput/Automationreports'+timeStamp+'/', takeScreenshotsOnlyOnFailures: true, screenshotsFolder: './screenshots', filePrefix: prePendStr+'report' }));}); },_/

Saurabh06 commented 8 years ago

but can you tell me how to resolve that issue or any alternative for that.?? Even though i have reinstalled protractor-jasmine2-html reporter module from npm but still it is giving same error I want a html reports using jasmine2 after test completiton